File size: 2,643 Bytes
1f23f65
 
 
 
 
 
77bddf4
1f23f65
 
 
eeeeda5
1f23f65
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
77bddf4
 
 
 
9583856
1f23f65
 
761bed4
9583856
761bed4
 
 
 
845e256
 
 
9583856
77bddf4
1f23f65
845e256
77bddf4
 
 
 
 
1f23f65
845e256
9583856
77bddf4
1f23f65
845e256
9583856
77bddf4
 
1f23f65
845e256
9583856
77bddf4
1f23f65
9583856
77bddf4
 
 
1f23f65
845e256
 
1f23f65
 
 
 
 
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#Imports
import pandas as pd
from sklearn.linear_model import LinearRegression
import gradio as gr

# Data Loading
house_data = './Indiahouse'
houses = pd.read_csv(house_data)

# Feature Selection
X_features = ['Area','living area','number of bedrooms','number of bathrooms','number of floors']
X = houses[X_features]
y_target = ['Price']
y = houses[y_target]

# Data Split
from sklearn.model_selection import train_test_split
X_train, X_test,y_train,y_test = train_test_split(X,y, train_size = 0.8, test_size = 0.2, random_state = 100)

# Modeling
lm = LinearRegression()
lm.fit(X_train, y_train)

# Gradio Function
def input(area,living_area,bedrooms,bathrooms,floors):
  input = [area,living_area,bedrooms,bathrooms,floors]
  output = lm.predict([input])
  return int(output)

demo = gr.Interface(
    input,
    [
        gr.Slider(minimum=800, maximum=18500, randomize=True, label="Area of the House ***(Sq.mtr)***"),
        gr.Slider(minimum=350, maximum=3000, randomize=True, step = 1,label="Living Area ***(Sq.mtr)***"),
        gr.Slider(minimum=1, maximum=4, randomize=True,step = 1, label="Number of Bedrooms"),
        gr.Slider(minimum=1, maximum=3, randomize=True,step = 1, label="Number of Bathrooms"),
        gr.Slider(minimum=1,maximum=3,randomize=True,step=1,label="Number of stories/Floors")
    ],
    "number",
    examples=[
        [1000, 400, 1, 1, 1],
        [2000,1200,2,3,1],
        [4000,1900,2,3,2],
        [28000,3000,5,3,3],
    ],
    title="Indian House Price Prediction Model",
    description="""
***Overview:***

This model predicts house prices in India using Linear Regression. Trained on key features like lot area, living area, bedrooms, bathrooms, and floors, it estimates house prices based on historical data.

***🚀Features:***
- Lot Area
- Living Area
- Bedrooms
- Bathrooms
- Floors

***⚒How it works:***

Linear Regression analyzes the relationship between input features and house prices, establishing a linear equation for predictions.

***📝Usage:***

1. Input specific values for lot area, living area, bedrooms, bathrooms, and floors.
2. Get an estimated house price based on the learned linear relationship.

***📊Disclaimer:***

This model provides estimations. Actual house prices may vary due to unconsidered factors. Consult real estate experts for precise valuations.

***🤗Model Info:***
- Mean Absolute Error (MAE): 0.11
- The Output of the Model depends on the DataSet
- For demo and learning purposes only.

***♥Feel free to explore and understand how key features influence house prices in India.♥***
"""
    )

if __name__ == "__main__":
    demo.launch()