<jupyter_start><jupyter_text>Looking for a new city? Try our City Search!City Search will ask you about a series of factors that affect where you would want to live and find you the right city for you.<jupyter_code>import pandas as pd
df = pd.read_csv('https://drive.google.com/uc?export=download&id=1x_zb2qUJkcoCgoCUmTxo8xQn9F7XHwoX')
import plotly.express as px
# df = px.data.gapminder()
# fig = px.choropleth(df, locations="iso_alpha", color="lifeExp", hover_name="country", animation_frame="year", range_color=[20,80])
# fig.show()
#@title Answer the following. The higher the answer, the more important a factor is in determining where you live.
#@markdown ---

#@markdown Economy
#@markdown ---
#@markdown How much emphasis do you place on the economy of where you're living?
gdp = 0 #@param {type:"slider", min:0, max:10, step:1}
#@markdown How important is purchasing power to you?
purchase_power = 10 #@param {type:"slider", min:0, max:10, step:1}
#@markdown How important is the cost of rent to you?
rent = 10 #@param {type:"slider", min:0, max:10, step:1}
#@markdown How important is having disposable income?
disposable_income = 10 #@param {type:"slider", min:0, max:10, step:1}
#@markdown ---

#@markdown Health
#@markdown ---
#@markdown How important is a country's healthcare quality and satisfaction?
health_care = 10 #@param {type:"slider", min:0, max:10, step:1}

#@markdown Is the life expectancy of where you want to live important?
life_expectancy = 10 #@param {type:"slider", min:0, max:10, step:1}

#@markdown ---

#@markdown Personal Values
#@markdown ---
#@markdown Is happinness important to you?
happiness_score = 0 #@param {type:"slider", min:0, max:10, step:1}
#@markdown How important is the quality of life?
quality_of_life = 10 #@param {type:"slider", min:0, max:10, step:1}
#@markdown Is it important to feel like you have a support system within your community?
social_support = 10 #@param {type:"slider", min:0, max:10, step:1}
#@markdown How much do you value your freedom?
freedom = 10 #@param {type:"slider", min:0, max:10, step:1}
#@markdown Do you care if the average person is generous?
generosity = 10 #@param {type:"slider", min:0, max:10, step:1}
#@markdown ---

#@markdown Common Purchases
#@markdown ---
#@markdown How often do you purchase coffee?
cappuccino = 10 #@param {type:"slider", min:0, max:10, step:1}

#@markdown How often do you go to the cinema?
cinema = 10 #@param {type:"slider", min:0, max:10, step:1}

#@markdown How often do you purchase wine?
wine = 10 #@param {type:"slider", min:0, max:10, step:1}

#@markdown Is the cost of gasoline important to you?
gasoline = 10 #@param {type:"slider", min:0, max:10, step:1}
#@markdown ---
#@markdown Potential Dangers
#@markdown ---
#@markdown How concerned are you about pollution?
pollution = 10 #@param {type:"slider", min:0, max:10, step:1}
#@markdown How concerned are you about crime?
crime_rating = 10 #@param {type:"slider", min:0, max:10, step:1}
#@markdown How concerned are you about business and government corruption?
corruption = 10 #@param {type:"slider", min:0, max:10, step:1}
#@markdown ---

#@markdown Miscellaneous
#@markdown ---
#@markdown How important is MoveHub's (https://www.movehub.com/city-rankings/) rating to you?
movehub_rating = 10 #@param {type:"slider", min:0, max:10, step:1}
#@markdown Is it important to you to live in a "developed" country?
hdi = 2 #@param {type:"slider", min:0, max:10, step:1}
#@markdown Would you like to have a lot of culturally significant sites in your country?
world_heritage_sites = 0 #@param {type:"slider", min:0, max:10, step:1}
#@markdown How important is it you to stay within the US?
international = 10 #@param {type:"slider", min:0, max:10, step:1}
#@markdown ---

import numpy as np

weights = [
  movehub_rating,
  purchase_power,
  health_care,
  quality_of_life,
  pollution,
  crime_rating,
  cappuccino,
  cinema,
  wine,
  gasoline,
  rent,
  disposable_income,
  hdi,
  happiness_score,
  gdp,
  social_support,
  life_expectancy,
  freedom,
  generosity,
  corruption,
  world_heritage_sites,
  international
]
#replace = {'None': 0, 'Low': 1, 'Med': 2, 'High': 3}
#weights = np.array([replace[x] for x in weights])
weights = np.array(weights)
weights *= [1, 1, 1, 1, -1, -1,-1,
            -1, -1, -1, -1, 1, 100, 1,
            100, 100, 100, 100, 100, -1000, 1,-100]

weights[11] = weights[11]/10

features = ['Movehub Rating', 'Purchase Power', 'Health Care', 'Quality of Life', 'Pollution', 'Crime Rating','Cappuccino',
            'Cinema', 'Wine', 'Gasoline', 'Avg Rent', 'Avg Disposable Income', 'HDI',
            'Happinness Score', 'GDP/capita', 'Social Support', 'Healthy Life Expectancy',
            'Freedom to make life choices', 'Generosity', 'Perception of Corruption', 'Country World Heritage Count',
            'International'] 
norm = lambda xs: (xs-xs.min())/(xs.max()-xs.min())

df['Score'] = norm(df[features].dot(weights))*100

fig = px.scatter_mapbox(df.sort_values('Score', ascending=False).round(),
                        lat="lat", lon="long", color="Score", hover_name="City",
                        hover_data=features,
                        color_continuous_scale="rainbow", size_max=30, zoom=1,
                        mapbox_style="open-street-map")
fig.show()

df.sort_values('Score', ascending=False)[['City', 'Country','Score'] + features]<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.14860107467111358, 'fraction_numerical': 0.03557531962201223, 'mean_word_length': 4.564948453608247, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 2, 'lorem ipsum': 0, 'www.': 1, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '246452', 'license': 'MIT', 'n_tokens_mistral': 1955, 'n_tokens_neox': 1779, 'n_words': 599, 'path': 'city_search.ipynb', 'repo_name': 'Quivun/Avocado_Ninjas', 'size': '5397'}