File size: 661 Bytes
7407839
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
# Filename: house_price_app.py

import gradio as gr
from sklearn.ensemble import RandomForestRegressor
import numpy as np

# Dummy training
model = RandomForestRegressor()
X = np.array([[1000, 2, 10], [1500, 3, 5], [2000, 4, 2]])
y = np.array([100000, 150000, 200000])
model.fit(X, y)

def predict(area, bedrooms, age):
    price = model.predict([[area, bedrooms, age]])
    return round(price[0], 2)

gr.Interface(
    fn=predict,
    inputs=[gr.Number(label="Area (sqft)"),
            gr.Number(label="Bedrooms"),
            gr.Number(label="Age (years)")],
    outputs=gr.Number(label="Predicted Price"),
    title="🏡 House Price Prediction"
).launch()