hmb HF Staff commited on
Commit
a5a21a1
·
verified ·
1 Parent(s): 6924eba

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +0 -73
app.py CHANGED
@@ -152,7 +152,6 @@ with gr.Blocks(js=js_func, css="""
152
  """) as demo:
153
  gr.HTML(elem_classes="title", value="🌍")
154
  gr.HTML("<img src='https://see.fontimg.com/api/rf5/JpZqa/MWMyNzc2ODk3OTFlNDk2OWJkY2VjYTIzNzFlY2E4MWIudHRm/bm9tYWQgZGVzdGluYXRpb25z/super-feel.png?r=fs&h=130&w=2000&fg=e2e2e2&bg=FFFFFF&tb=1&s=65' alt='Graffiti fonts'></a>")
155
-
156
  gr.Markdown("Discover the best places for digital nomads around the globe")
157
 
158
  with gr.Row():
@@ -338,77 +337,5 @@ with gr.Blocks(js=js_func, css="""
338
  "- Consider internet speed if you need to attend video meetings \n"
339
  "- Balance cost of living with quality of life for the best experience \n"
340
  "- Some newer nomad destinations may have incomplete data")
341
-
342
-
343
- gr.Markdown("### 🎯 Find Your Ideal Destination")
344
- with gr.Row():
345
- with gr.Column():
346
- priority = gr.CheckboxGroup(
347
- ["Best Quality of Life", "Fastest Internet", "Most Affordable", "Balance of All Factors"],
348
- label="What are Your Priorities?",
349
- value=["Balance of All Factors"]
350
- )
351
-
352
- find_btn = gr.Button("Find My Ideal Destination", variant="primary")
353
-
354
- recommendation = gr.Textbox(label="Recommended Location", lines=3)
355
-
356
- def recommend_location(priorities, max_budget):
357
- if not priorities:
358
- return "Please select at least one priority to get a recommendation."
359
-
360
- budget_filtered_df = df[df["Monthly Cost Living (USD)"] <= max_budget]
361
-
362
- budget_warning = ""
363
- if len(budget_filtered_df) == 0:
364
- budget_filtered_df = df
365
- budget_warning = "⚠️ No cities match your budget. Showing best options regardless of cost.\n\n"
366
-
367
- recommendations = []
368
-
369
- if "Best Quality of Life" in priorities:
370
- top_city = budget_filtered_df.sort_values("Quality of Life", ascending=False).iloc[0]
371
- terrain_emoji = terrain_emoji_map.get(top_city['Terrain'], top_city['Terrain']).split()[0]
372
- message = f"{terrain_emoji} {top_city['City']}, {top_city['Country']} - Quality of Life: {top_city['Quality of Life']}\n"
373
- message += f"Monthly Cost: ${top_city['Monthly Cost Living (USD)']}\n"
374
- message += f"Key Feature: {top_city['Key Feature']}"
375
- recommendations.append(message)
376
-
377
- if "Fastest Internet" in priorities:
378
- top_city = budget_filtered_df.sort_values("Internet Speed (Mbps)", ascending=False).iloc[0]
379
- terrain_emoji = terrain_emoji_map.get(top_city['Terrain'], top_city['Terrain']).split()[0]
380
- message = f"{terrain_emoji} {top_city['City']}, {top_city['Country']} - Internet Speed: {top_city['Internet Speed (Mbps)']} Mbps\n"
381
- message += f"Monthly Cost: ${top_city['Monthly Cost Living (USD)']}\n"
382
- message += f"Key Feature: {top_city['Key Feature']}"
383
- recommendations.append(message)
384
-
385
- if "Most Affordable" in priorities:
386
- top_city = budget_filtered_df.sort_values("Monthly Cost Living (USD)", ascending=True).iloc[0]
387
- terrain_emoji = terrain_emoji_map.get(top_city['Terrain'], top_city['Terrain']).split()[0]
388
- message = f"{terrain_emoji} {top_city['City']}, {top_city['Country']} - Monthly Cost: ${top_city['Monthly Cost Living (USD)']}\n"
389
- message += f"Quality of Life: {top_city['Quality of Life']}, Internet: {top_city['Internet Speed (Mbps)']} Mbps\n"
390
- message += f"Key Feature: {top_city['Key Feature']}"
391
- recommendations.append(message)
392
-
393
- if "Balance of All Factors" in priorities:
394
- df_temp = budget_filtered_df.copy()
395
- df_temp['quality_norm'] = df_temp['Quality of Life'] / 10
396
- df_temp['internet_norm'] = df_temp['Internet Speed (Mbps)'] / 400
397
- df_temp['cost_norm'] = 1 - (df_temp['Monthly Cost Living (USD)'] / 4000)
398
-
399
- df_temp['composite_score'] = (df_temp['quality_norm'] + df_temp['internet_norm'] + df_temp['cost_norm']) / 3
400
- top_city = df_temp.sort_values("composite_score", ascending=False).iloc[0]
401
-
402
- terrain_emoji = terrain_emoji_map.get(top_city['Terrain'], top_city['Terrain']).split()[0]
403
- message = f"{terrain_emoji} {top_city['City']}, {top_city['Country']} - Balanced Choice\n"
404
- message += f"Quality: {top_city['Quality of Life']}, Internet: {top_city['Internet Speed (Mbps)']} Mbps, Cost: ${top_city['Monthly Cost Living (USD)']}\n"
405
- message += f"Key Feature: {top_city['Key Feature']}"
406
- recommendations.append(message)
407
-
408
- return budget_warning + "\n\n".join(recommendations)
409
-
410
- find_btn.click(recommend_location, inputs=[priority, cost_slider], outputs=recommendation)
411
-
412
- cost_slider.change(recommend_location, inputs=[priority, cost_slider], outputs=recommendation)
413
 
414
  demo.launch()
 
152
  """) as demo:
153
  gr.HTML(elem_classes="title", value="🌍")
154
  gr.HTML("<img src='https://see.fontimg.com/api/rf5/JpZqa/MWMyNzc2ODk3OTFlNDk2OWJkY2VjYTIzNzFlY2E4MWIudHRm/bm9tYWQgZGVzdGluYXRpb25z/super-feel.png?r=fs&h=130&w=2000&fg=e2e2e2&bg=FFFFFF&tb=1&s=65' alt='Graffiti fonts'></a>")
 
155
  gr.Markdown("Discover the best places for digital nomads around the globe")
156
 
157
  with gr.Row():
 
337
  "- Consider internet speed if you need to attend video meetings \n"
338
  "- Balance cost of living with quality of life for the best experience \n"
339
  "- Some newer nomad destinations may have incomplete data")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
340
 
341
  demo.launch()