tajuarAkash commited on
Commit
0b93e3c
·
verified ·
1 Parent(s): bae07ff

Upload 4 files

Browse files
Files changed (4) hide show
  1. app.py +57 -0
  2. model.pkl +3 -0
  3. requirements.txt +5 -0
  4. scaler.pkl +3 -0
app.py ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import pickle
3
+ import numpy as np
4
+
5
+ # Load model and scaler
6
+ model = pickle.load(open('model.pkl', 'rb'))
7
+ scaler = pickle.load(open('scaler.pkl', 'rb'))
8
+
9
+ def predict_price(area, bedrooms, bathrooms, stories, parking, mainroad, guestroom,
10
+ basement, hotwaterheating, airconditioning, prefarea, furnishingstatus):
11
+
12
+ # Encode inputs
13
+ mainroad = 1.0 if mainroad == "Yes" else 0.0
14
+ guestroom = 1.0 if guestroom == "Yes" else 0.0
15
+ basement = 1.0 if basement == "Yes" else 0.0
16
+ hotwaterheating = 1.0 if hotwaterheating == "Yes" else 0.0
17
+ airconditioning = 1.0 if airconditioning == "Yes" else 0.0
18
+ prefarea = 1.0 if prefarea == "Yes" else 0.0
19
+
20
+ furnishing_map = {"furnished": 0.0, "semi-furnished": 1.0, "unfurnished": 2.0}
21
+ furnishingstatus = furnishing_map[furnishingstatus]
22
+
23
+ # Create input array
24
+ input_data = np.array([[area, bedrooms, bathrooms, stories,
25
+ mainroad, guestroom, basement,
26
+ hotwaterheating, airconditioning,
27
+ parking, prefarea, furnishingstatus]])
28
+
29
+ # Scale and predict
30
+ input_scaled = scaler.transform(input_data)
31
+ prediction = model.predict(input_scaled)
32
+
33
+ return f" {prediction[0]:,.2f}"
34
+
35
+ # Create Gradio interface
36
+ demo = gr.Interface(
37
+ fn=predict_price,
38
+ inputs=[
39
+ gr.Number(label="Area (sq ft)", value=5000),
40
+ gr.Dropdown(choices=[1, 2, 3, 4, 5, 6], label="Bedrooms", value=3),
41
+ gr.Dropdown(choices=[1, 2, 3, 4], label="Bathrooms", value=2),
42
+ gr.Dropdown(choices=[1, 2, 3, 4], label="Stories", value=2),
43
+ gr.Dropdown(choices=[0, 1, 2, 3], label="Parking", value=1),
44
+ gr.Dropdown(choices=["Yes", "No"], label="Main Road", value="Yes"),
45
+ gr.Dropdown(choices=["Yes", "No"], label="Guest Room", value="No"),
46
+ gr.Dropdown(choices=["Yes", "No"], label="Basement", value="No"),
47
+ gr.Dropdown(choices=["Yes", "No"], label="Hot Water Heating", value="No"),
48
+ gr.Dropdown(choices=["Yes", "No"], label="Air Conditioning", value="Yes"),
49
+ gr.Dropdown(choices=["Yes", "No"], label="Preferred Area", value="Yes"),
50
+ gr.Dropdown(choices=["furnished", "semi-furnished", "unfurnished"], label="Furnishing", value="furnished")
51
+ ],
52
+ outputs=gr.Textbox(label="Predicted Price"),
53
+ title="🏠 House Price Prediction",
54
+ description="Enter house features to predict the price"
55
+ )
56
+
57
+ demo.launch(share=True)
model.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:fcec7203319cff3c36f108dd94eb82ed35514feda60d6c0073f00b1d2b8b1c5e
3
+ size 596
requirements.txt ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ gradio
2
+ streamlit
3
+ pandas
4
+ scikit-learn
5
+ numpy
scaler.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1614a15b27dea586aeb6ed1bbb9104c053cafe2aaeb801dfa318843c60bee211
3
+ size 1199