Koaris commited on
Commit
99bf7e7
·
verified ·
1 Parent(s): b7aacd0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -4
app.py CHANGED
@@ -37,19 +37,19 @@ def predict_price(date: datetime ,room_count: int, address:str, surface: float ,
37
  isHouse = (property_type == 'Maison')
38
  rf_input = pd.DataFrame([{"date_mutation": date, "nombre_pieces_principales": room_count, "longitude" : longitude,"latitude":latitude, "surface_batie_totale": surface, "type_local_Maison": isHouse}])
39
  print(rf_input)
40
- rf_pred = rf.predict(rf_input)[0]
41
  predictions_all = np.array([tree.predict(rf_input) for tree in rf.estimators_])
42
  std_predict = np.std(predictions_all)
43
  reliability_index = compute_reliability(std_predict)
44
  q1 = np.exp(np.quantile(predictions_all, 0.25))
45
  q2 = np.exp(np.quantile(predictions_all, 0.5))
46
  q3 = np.exp(np.quantile(predictions_all, 0.75))
47
- if (rf_pred_exp <= q1) | (rf_pred_exp >= q3):
48
  print(f"Estimated Price: {np.exp(q2)} /n Low Price: {q1}, High Price: {q3}")
49
  return float(q1), float(q2), float(q3), reliability_index
50
  else:
51
- print(f"Estimated Price: {rf_pred_exp} /n Low Price: {q1}, High Price: {q3}")
52
- return float(q1), float(rf_pred_exp), float(q3), reliability_index
53
 
54
 
55
 
 
37
  isHouse = (property_type == 'Maison')
38
  rf_input = pd.DataFrame([{"date_mutation": date, "nombre_pieces_principales": room_count, "longitude" : longitude,"latitude":latitude, "surface_batie_totale": surface, "type_local_Maison": isHouse}])
39
  print(rf_input)
40
+ rf_pred = np.exp(rf.predict(rf_input)[0])
41
  predictions_all = np.array([tree.predict(rf_input) for tree in rf.estimators_])
42
  std_predict = np.std(predictions_all)
43
  reliability_index = compute_reliability(std_predict)
44
  q1 = np.exp(np.quantile(predictions_all, 0.25))
45
  q2 = np.exp(np.quantile(predictions_all, 0.5))
46
  q3 = np.exp(np.quantile(predictions_all, 0.75))
47
+ if (rf_pred <= q1) | (rf_pred >= q3):
48
  print(f"Estimated Price: {np.exp(q2)} /n Low Price: {q1}, High Price: {q3}")
49
  return float(q1), float(q2), float(q3), reliability_index
50
  else:
51
+ print(f"Estimated Price: {rf_pred} /n Low Price: {q1}, High Price: {q3}")
52
+ return float(q1), float(rf_pred), float(q3), reliability_index
53
 
54
 
55