Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -7,6 +7,40 @@ import joblib
|
|
| 7 |
repo_id = "rmaitest/mlmodel2"
|
| 8 |
model_file = "house_price_model.pkl" # Adjust as necessary
|
| 9 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
# Download and load the model
|
| 11 |
model_path = hf_hub_download(repo_id, model_file)
|
| 12 |
model = joblib.load(model_path)
|
|
|
|
| 7 |
repo_id = "rmaitest/mlmodel2"
|
| 8 |
model_file = "house_price_model.pkl" # Adjust as necessary
|
| 9 |
|
| 10 |
+
# Download and load the model
|
| 11 |
+
model_path = hf_hub_download(repo_id, model_file)
|
| 12 |
+
model = joblib.load(model_path)
|
| 13 |
+
|
| 14 |
+
def predict_price(size, bedrooms, age):
|
| 15 |
+
# Create a DataFrame from the input
|
| 16 |
+
input_data = pd.DataFrame({
|
| 17 |
+
'Size (sq ft)': [size],
|
| 18 |
+
'Number of Bedrooms': [bedrooms],
|
| 19 |
+
'Age of House (years)': [age]
|
| 20 |
+
})
|
| 21 |
+
|
| 22 |
+
# Make prediction
|
| 23 |
+
prediction = model.predict(input_data)
|
| 24 |
+
return prediction[0]
|
| 25 |
+
|
| 26 |
+
# Define the Gradio interface
|
| 27 |
+
iface = gr.Interface(
|
| 28 |
+
fn=predict_price,
|
| 29 |
+
inputs=[
|
| 30 |
+
gr.Number(label="Size (sq ft)"),
|
| 31 |
+
gr.Number(label="Number of Bedrooms"),
|
| 32 |
+
gr.Number(label="Age of House (years)")
|
| 33 |
+
],
|
| 34 |
+
outputs=gr.Number(label="Predicted Price ($)"),
|
| 35 |
+
title="House Price Prediction",
|
| 36 |
+
description="Enter the size, number of bedrooms, and age of the house to get the predicted price."
|
| 37 |
+
)
|
| 38 |
+
|
| 39 |
+
# Launch the interface
|
| 40 |
+
if __name__ == "__main__":
|
| 41 |
+
iface.launch()
|
| 42 |
+
|
| 43 |
+
|
| 44 |
# Download and load the model
|
| 45 |
model_path = hf_hub_download(repo_id, model_file)
|
| 46 |
model = joblib.load(model_path)
|