| | import gradio as gr |
| | import joblib |
| | import numpy as np |
| | import pandas as pd |
| |
|
| | |
| | model = joblib.load("house_price_model.joblib") |
| |
|
| | |
| | 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}" |
| |
|
| | |
| | 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() |
| |
|