|
import gradio as gr |
|
import joblib |
|
import numpy as np |
|
|
|
|
|
model = joblib.load('best_random_forest_model.pkl') |
|
scaler = joblib.load('scaler.pkl') |
|
|
|
def predict_house_price(feature1, feature2, feature3, feature4, feature5): |
|
|
|
features = [feature1, feature2, feature3, feature4, feature5] |
|
|
|
|
|
scaled_features = scaler.transform([features]) |
|
|
|
|
|
prediction = model.predict(scaled_features) |
|
|
|
return f"Predicted House Price: ${prediction[0]:,.2f}" |
|
|
|
|
|
interface = gr.Interface( |
|
fn=predict_house_price, |
|
inputs=[ |
|
gr.Number(label="Feature 1: (e.g., Average number of rooms per dwelling)"), |
|
gr.Number(label="Feature 2: (e.g., Total rooms)"), |
|
gr.Number(label="Feature 3: (e.g., Total bedrooms)"), |
|
gr.Number(label="Feature 4: (e.g., Median age of houses)"), |
|
gr.Number(label="Feature 5: (e.g., Population)"), |
|
], |
|
outputs=gr.Textbox(label="Predicted House Price"), |
|
description="Predict California house prices based on input features.", |
|
title="California House Price Predictor" |
|
) |
|
|
|
|
|
interface.launch() |
|
|