Pravincoder commited on
Commit
1f23f65
·
verified ·
1 Parent(s): cfaabe3

Create app.py

Browse files

Added the app.py

Files changed (1) hide show
  1. app.py +74 -0
app.py ADDED
@@ -0,0 +1,74 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #Imports
2
+ import pandas as pd
3
+ from sklearn.linear_model import LinearRegression
4
+ import gradio as gr
5
+
6
+ # Data Loading
7
+ house_data = '/content/drive/MyDrive/India_house_Price300'
8
+ houses = pd.read_csv(house_data)
9
+
10
+ # Feature Selection
11
+ X_features = ['lot area','living area','number of bedrooms','number of bathrooms','number of floors']
12
+ X = houses[X_features]
13
+ y_target = ['Price']
14
+ y = houses[y_target]
15
+
16
+ # Data Split
17
+ from sklearn.model_selection import train_test_split
18
+ X_train, X_test,y_train,y_test = train_test_split(X,y, train_size = 0.8, test_size = 0.2, random_state = 100)
19
+
20
+ # Modeling
21
+ lm = LinearRegression()
22
+ lm.fit(X_train, y_train)
23
+
24
+ # Gradio Function
25
+ def input(area,living_area,bedrooms,bathrooms,floors):
26
+ input = [area,living_area,bedrooms,bathrooms,floors]
27
+ output = lm.predict([input])
28
+ return int(output)
29
+
30
+ demo = gr.Interface(
31
+ input,
32
+ [
33
+ gr.Slider(minimum=1000, maximum=30000, randomize=True, label="Area of the House"),
34
+ gr.Slider(minimum=600, maximum=7000, randomize=True, step = 1,label="Living Area"),
35
+ gr.Slider(minimum=1, maximum=8, randomize=True,step = 1, label="Number of Bedrooms"),
36
+ gr.Slider(minimum=1, maximum=5, randomize=True,step = 1, label="Number of Bathrooms"),
37
+ gr.Slider(minimum=1,maximum=3.5,randomize=True,step=0.5,label="Number of stories/Floors")
38
+ ],
39
+ "number",
40
+ title="Indian House Price Prediction Model",
41
+ description='''***Overview:***
42
+
43
+ This Gradio-powered Indian House Prediction Model employs Linear Regression to estimate house prices based on essential features. The model is trained on a dataset that includes key factors influencing house prices in India.
44
+
45
+ ***Features:***
46
+
47
+ Lot Area: The total area of the plot on which the house is built.
48
+ Living Area: The total living space within the house.
49
+ Number of Bedrooms: The count of bedrooms in the house.
50
+ Number of Bathrooms: The count of bathrooms in the house.
51
+ Number of Floors: The total number of floors in the house.
52
+
53
+ ***How it works:***
54
+
55
+ *Linear Regression analyzes the relationship between these features and the house prices. By learning from historical data, the model establishes a linear equation that maps these input features to the predicted house price.*
56
+
57
+ ***Usage:***
58
+
59
+ Input Features: Users input the specific values for the house's lot area, living area, number of bedrooms, bathrooms, and floors.
60
+ Prediction: The model processes these inputs and provides an estimated house price based on the learned linear relationship.
61
+ Application:
62
+
63
+ This predictive model is valuable for individuals in the Indian real estate market looking to get an approximate idea of house prices based on specific characteristics. It can be a useful tool for property buyers, sellers, and real estate professionals to make informed decisions.
64
+
65
+ ***Disclaimer:***
66
+
67
+ While this model provides estimations, actual house prices may vary due to additional factors not considered in this model. It is advisable to consult with real estate experts for precise valuations.
68
+
69
+ Feel free to customize this description based on any additional details or specific characteristics of your model'''
70
+ )
71
+
72
+ if __name__ == "__main__":
73
+ demo.launch()
74
+