Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -23,11 +23,8 @@ def get_lat_lon(address,api_key=API_KEY):
|
|
| 23 |
def compute_reliability(std_pred: float):
|
| 24 |
scores = pd.read_csv('scores_13072024.csv').iloc[:,1].tolist()
|
| 25 |
print(scores)
|
| 26 |
-
ct =
|
| 27 |
for std_set in scores:
|
| 28 |
-
print(ct)
|
| 29 |
-
print(std_set)
|
| 30 |
-
print(std_pred)
|
| 31 |
if std_pred < std_set:
|
| 32 |
reliability = ct
|
| 33 |
else:
|
|
@@ -37,11 +34,9 @@ def compute_reliability(std_pred: float):
|
|
| 37 |
|
| 38 |
def predict_price(date: datetime ,room_count: int, address:str, surface: float , property_type: str ):
|
| 39 |
date = int(datetime.timestamp(date))
|
| 40 |
-
print(date)
|
| 41 |
latitude, longitude = get_lat_lon(address)
|
| 42 |
isHouse = (property_type == 'Maison')
|
| 43 |
rf_input = pd.DataFrame([{"date_mutation": date, "nombre_pieces_principales": room_count, "longitude" : longitude,"latitude":latitude, "surface_batie_totale": surface, "type_local_Maison": isHouse}])
|
| 44 |
-
print(rf_input)
|
| 45 |
rf_pred = np.exp(rf.predict(rf_input)[0])
|
| 46 |
predictions_all = np.array([tree.predict(rf_input) for tree in rf.estimators_])
|
| 47 |
std_predict = np.std((predictions_all))
|
|
@@ -50,10 +45,8 @@ def predict_price(date: datetime ,room_count: int, address:str, surface: float ,
|
|
| 50 |
q2 = np.exp(np.quantile(predictions_all, 0.5))
|
| 51 |
q3 = np.exp(np.quantile(predictions_all, 0.75))
|
| 52 |
if (rf_pred <= q1) | (rf_pred >= q3):
|
| 53 |
-
print(f"Estimated Price: {np.exp(q2)} /n Low Price: {q1}, High Price: {q3}")
|
| 54 |
return float(q1), float(q2), float(q3), reliability_index
|
| 55 |
else:
|
| 56 |
-
print(f"Estimated Price: {rf_pred} /n Low Price: {q1}, High Price: {q3}")
|
| 57 |
return float(q1), float(rf_pred), float(q3), reliability_index
|
| 58 |
|
| 59 |
|
|
|
|
| 23 |
def compute_reliability(std_pred: float):
|
| 24 |
scores = pd.read_csv('scores_13072024.csv').iloc[:,1].tolist()
|
| 25 |
print(scores)
|
| 26 |
+
ct = 10
|
| 27 |
for std_set in scores:
|
|
|
|
|
|
|
|
|
|
| 28 |
if std_pred < std_set:
|
| 29 |
reliability = ct
|
| 30 |
else:
|
|
|
|
| 34 |
|
| 35 |
def predict_price(date: datetime ,room_count: int, address:str, surface: float , property_type: str ):
|
| 36 |
date = int(datetime.timestamp(date))
|
|
|
|
| 37 |
latitude, longitude = get_lat_lon(address)
|
| 38 |
isHouse = (property_type == 'Maison')
|
| 39 |
rf_input = pd.DataFrame([{"date_mutation": date, "nombre_pieces_principales": room_count, "longitude" : longitude,"latitude":latitude, "surface_batie_totale": surface, "type_local_Maison": isHouse}])
|
|
|
|
| 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))
|
|
|
|
| 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 |
return float(q1), float(q2), float(q3), reliability_index
|
| 49 |
else:
|
|
|
|
| 50 |
return float(q1), float(rf_pred), float(q3), reliability_index
|
| 51 |
|
| 52 |
|