fschwartzer commited on
Commit
f96846f
1 Parent(s): d9189c2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -1
app.py CHANGED
@@ -227,8 +227,18 @@ with st.container():
227
  # Set the threshold (k) for the number of data points
228
  k_threshold = 5 # Adjust the threshold as needed
229
 
230
- # Display the predicted Predicted_target values if applicable and above the threshold
231
  if 'Predicted_target' in filtered_data.columns and len(filtered_data) > k_threshold:
 
 
 
 
 
 
 
 
 
 
232
  st.write("Valores (R$/m²) previstos com algoritmo KNN:")
233
  st.write(filtered_data[['Localização', 'Atotal', 'Apriv', 'Vunit_total', 'Vunit_priv', 'Predicted_target']])
234
  else:
 
227
  # Set the threshold (k) for the number of data points
228
  k_threshold = 5 # Adjust the threshold as needed
229
 
230
+ # Check if there is data for prediction
231
  if 'Predicted_target' in filtered_data.columns and len(filtered_data) > k_threshold:
232
+ # Determine which area feature to use for prediction
233
+ filtered_data['area_feature'] = np.where(filtered_data['Apriv'] != 0, filtered_data['Apriv'], filtered_data['Atotal'])
234
+
235
+ # Apply KNN and get predicted Predicted_target values
236
+ predicted_target = knn_predict(filtered_data, 'Predicted_target', ['latitude', 'longitude', 'area_feature']) # Update with your features
237
+
238
+ # Add predicted Predicted_target values to filtered_data
239
+ filtered_data['Predicted_target'] = predicted_target
240
+
241
+ # Display the predicted Predicted_target values
242
  st.write("Valores (R$/m²) previstos com algoritmo KNN:")
243
  st.write(filtered_data[['Localização', 'Atotal', 'Apriv', 'Vunit_total', 'Vunit_priv', 'Predicted_target']])
244
  else: