GaboDataScientist commited on
Commit
130a4db
·
verified ·
1 Parent(s): 384abaf

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -1
app.py CHANGED
@@ -5,6 +5,7 @@ from joblib import load
5
 
6
  best_model=load('./RandomForestRegressorVentaCasas.joblib')
7
  # Suponiendo que 'best_model' y 'X_train' están definidos en tu entorno
 
8
 
9
  def predict_price(rooms, bathroom, size, parking):
10
  new_property_data = pd.DataFrame({
@@ -14,7 +15,7 @@ def predict_price(rooms, bathroom, size, parking):
14
  'Estacionamiento': [parking]
15
  })
16
  # Asegúrate de que las columnas estén en el mismo orden que X_train
17
- new_property_data = new_property_data[X_train.columns]
18
  predicted_price = best_model.predict(new_property_data)
19
  return f"${predicted_price[0]:,.2f}"
20
 
 
5
 
6
  best_model=load('./RandomForestRegressorVentaCasas.joblib')
7
  # Suponiendo que 'best_model' y 'X_train' están definidos en tu entorno
8
+ feature_order = ['Habitaciones', 'Baño', 'Tamaño', 'Estacionamiento']
9
 
10
  def predict_price(rooms, bathroom, size, parking):
11
  new_property_data = pd.DataFrame({
 
15
  'Estacionamiento': [parking]
16
  })
17
  # Asegúrate de que las columnas estén en el mismo orden que X_train
18
+ new_property_data = new_property_data[feature_order]
19
  predicted_price = best_model.predict(new_property_data)
20
  return f"${predicted_price[0]:,.2f}"
21