Download app.py from LonewolfT141/House-Price-Predicting-Model: direct link, hf CLI and curl.
- Browser
- Download file 1.38 kB
-
https://huggingface.co/LonewolfT141/House-Price-Predicting-Model/resolve/main/app.py
- Command line
-
hf download hf://LonewolfT141/House-Price-Predicting-Model/app.py
-
curl -L -o app.py https://huggingface.co/LonewolfT141/House-Price-Predicting-Model/resolve/main/app.py
1.38 kB
| import gradio as gr | |
| import joblib | |
| import numpy as np | |
| import pandas as pd | |
| # Load the model | |
| model = joblib.load("house_price_model.joblib") # or use linear_regression_model.pkl if preferred | |
| # Define input columns (must match training data!) | |
| input_cols = ['OverallQual', 'GrLivArea', 'GarageCars', 'TotalBsmtSF', '1stFlrSF', 'FullBath', 'YearBuilt'] | |
| def predict_price(OverallQual, GrLivArea, GarageCars, TotalBsmtSF, FirstFlrSF, FullBath, YearBuilt): | |
| data = pd.DataFrame([[OverallQual, GrLivArea, GarageCars, TotalBsmtSF, FirstFlrSF, FullBath, YearBuilt]], | |
| columns=input_cols) | |
| prediction = model.predict(data)[0] | |
| return f"Estimated House Price: ${prediction:,.2f}" | |
| # Gradio Interface | |
| demo = gr.Interface( | |
| fn=predict_price, | |
| inputs=[ | |
| gr.Slider(1, 10, value=5, label="Overall Quality"), | |
| gr.Number(label="Above Ground Living Area (GrLivArea)"), | |
| gr.Slider(0, 4, step=1, label="Garage Cars"), | |
| gr.Number(label="Total Basement Area (TotalBsmtSF)"), | |
| gr.Number(label="First Floor Area (1stFlrSF)"), | |
| gr.Slider(0, 3, step=1, label="Full Bathrooms"), | |
| gr.Number(label="Year Built"), | |
| ], | |
| outputs="text", | |
| title="🏡 House Price Predictor", | |
| description="Enter the house details and get an estimated price using a trained ML model." | |
| ) | |
| if __name__ == "__main__": | |
| demo.launch() | |