vlntnstarodub commited on
Commit
d05c0d5
·
1 Parent(s): 26ec0a4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -5
app.py CHANGED
@@ -142,9 +142,8 @@ def geo_plot_ml_recommendation():
142
  # Ensure swiped_images has the same categories as read_dat['groups']
143
  swiped_images['image_category'] = swiped_images['image_category'].astype('category')
144
  swiped_images['image_category'] = swiped_images['image_category'].cat.set_categories(le.classes_)
145
-
146
  if uploaded_files:
147
- data_to_concat = []
148
  for i, file in enumerate(uploaded_files):
149
  img = Image.open(file)
150
  st.image(img, caption=f"Uploaded Image {i + 1}", use_column_width=True)
@@ -185,17 +184,18 @@ def geo_plot_ml_recommendation():
185
  read_dat['lat'] = read_dat['location'].apply(lambda x: ast.literal_eval(x)['lat'])
186
  read_dat['lng'] = read_dat['location'].apply(lambda x: ast.literal_eval(x)['lng'])
187
 
188
- recommended_locations = read_dat[read_dat['encoded_category'] == majority_category[0]][['lat', 'lng']]
189
  recommended_locations['distance'] = recommended_locations.apply(
190
  lambda row: geodesic(current_location, (row['lat'], row['lng'])).kilometers, axis=1
191
  )
192
 
193
  closest_location = recommended_locations.loc[recommended_locations['distance'].idxmin()]
194
-
195
  # Plot Geo Plot with ML Recommendation
196
  fig = px.scatter_mapbox(recommended_locations,
197
  lat='lat',
198
  lon='lng',
 
199
  hover_data=['distance'],
200
  mapbox_style="open-street-map",
201
  zoom=10,
@@ -218,7 +218,7 @@ def geo_plot_ml_recommendation():
218
  st.plotly_chart(fig)
219
 
220
  st.write("Closest Recommended Location:")
221
- st.write(closest_location[['lat', 'lng']])
222
  st.write("Distance to Closest Location:", closest_location['distance'], "kilometers")
223
 
224
 
 
142
  # Ensure swiped_images has the same categories as read_dat['groups']
143
  swiped_images['image_category'] = swiped_images['image_category'].astype('category')
144
  swiped_images['image_category'] = swiped_images['image_category'].cat.set_categories(le.classes_)
145
+ data_to_concat = []
146
  if uploaded_files:
 
147
  for i, file in enumerate(uploaded_files):
148
  img = Image.open(file)
149
  st.image(img, caption=f"Uploaded Image {i + 1}", use_column_width=True)
 
184
  read_dat['lat'] = read_dat['location'].apply(lambda x: ast.literal_eval(x)['lat'])
185
  read_dat['lng'] = read_dat['location'].apply(lambda x: ast.literal_eval(x)['lng'])
186
 
187
+ recommended_locations = read_dat[read_dat['encoded_category'] == majority_category[0]][['lat', 'lng', 'title']]
188
  recommended_locations['distance'] = recommended_locations.apply(
189
  lambda row: geodesic(current_location, (row['lat'], row['lng'])).kilometers, axis=1
190
  )
191
 
192
  closest_location = recommended_locations.loc[recommended_locations['distance'].idxmin()]
193
+ print(recommended_locations)
194
  # Plot Geo Plot with ML Recommendation
195
  fig = px.scatter_mapbox(recommended_locations,
196
  lat='lat',
197
  lon='lng',
198
+ text='title', # Include the 'title' column for text in the plot
199
  hover_data=['distance'],
200
  mapbox_style="open-street-map",
201
  zoom=10,
 
218
  st.plotly_chart(fig)
219
 
220
  st.write("Closest Recommended Location:")
221
+ st.write(closest_location[['lat', 'lng', 'title']])
222
  st.write("Distance to Closest Location:", closest_location['distance'], "kilometers")
223
 
224