Spaces:
Sleeping
Sleeping
| import gradio as gr | |
| import joblib | |
| import numpy as np | |
| # Load trained model | |
| model = joblib.load("model/house_price_model.pkl") | |
| # Define prediction function | |
| def predict_price(rm, lstat, ptratio): | |
| input_data = np.array([[rm, lstat, ptratio]]) | |
| prediction = model.predict(input_data)[0] | |
| return round(prediction, 2) | |
| # Define Gradio interface | |
| iface = gr.Interface( | |
| fn=predict_price, | |
| inputs=[ | |
| gr.Slider(3.0, 9.0, step=0.1, label="Average Rooms (RM)"), | |
| gr.Slider(1.0, 40.0, step=0.1, label="Lower Status Population (%) (LSTAT)"), | |
| gr.Slider(12.0, 22.0, step=0.1, label="Pupil-Teacher Ratio (PTRATIO)") | |
| ], | |
| outputs=gr.Number(label="Predicted House Price (in $1000s)"), | |
| title="🏠 Boston Housing Price Predictor", | |
| description="Enter the house features to predict the price using a linear regression model.", | |
| ) | |
| # Launch app | |
| iface.launch() | |