Spaces:
Sleeping
Sleeping
File size: 889 Bytes
0aaf3d6 d7fe6e1 acfa0e5 0aaf3d6 084fa81 acfa0e5 0aaf3d6 acfa0e5 084fa81 0aaf3d6 acfa0e5 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
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()
|