Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,89 +1,57 @@
|
|
1 |
-
import
|
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 |
-
st.subheader('Housing Data')
|
59 |
-
st.write(user_data)
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
# MODEL
|
65 |
-
lr = LinearRegression()
|
66 |
-
lr.fit(x_train, y_train)
|
67 |
-
user_result = lr.predict(user_data)
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
# VISUALISATIONS
|
72 |
-
st.title('Visualised Housing Data')
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
# COLOR FUNCTION
|
77 |
-
if user_result[0]==0:
|
78 |
-
color = 'blue'
|
79 |
-
else:
|
80 |
-
color = 'red'
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
# OUTPUT
|
85 |
-
st.subheader('Price of House is : ')
|
86 |
-
st.write(str(user_result))
|
87 |
-
st.title('output')
|
88 |
-
st.subheader('r2_score: ')
|
89 |
-
st.write(str(r2_score(y_test, lr.predict(x_test))*100)+'%')
|
|
|
1 |
+
import pickle as pkl
|
2 |
+
|
3 |
+
#Step 2: Open the saved file with read-binary mode
|
4 |
+
lr_pickle = pkl.load(open('linear_saved_model', 'rb'))
|
5 |
+
|
6 |
+
# FUNCTION
|
7 |
+
def user_report():
|
8 |
+
Income = st.sidebar.slider('Income', 17795,107702, 18000 )
|
9 |
+
House_age = st.sidebar.slider('House_age', 2,10, 4 )
|
10 |
+
No_rooms = st.sidebar.slider('No_rooms', 3,11, 5 )
|
11 |
+
No_bedrooms = st.sidebar.slider('No_bedrooms', 2,7, 3 )
|
12 |
+
population = st.sidebar.slider('population', 170,70000, 5000 )
|
13 |
+
|
14 |
+
|
15 |
+
user_report_data = {
|
16 |
+
'Income':Income,
|
17 |
+
'House_age':House_age,
|
18 |
+
'No_rooms':No_rooms,
|
19 |
+
'No_bedrooms':No_bedrooms,
|
20 |
+
'population':population
|
21 |
+
}
|
22 |
+
report_data = pd.DataFrame(user_report_data, index=[0])
|
23 |
+
return report_data
|
24 |
+
|
25 |
+
|
26 |
+
|
27 |
+
|
28 |
+
# Housing Data
|
29 |
+
user_data = user_report()
|
30 |
+
st.subheader('Housing Data')
|
31 |
+
st.write(user_data)
|
32 |
+
|
33 |
+
|
34 |
+
|
35 |
+
|
36 |
+
# MODEL
|
37 |
+
user_result = lr_pickle.predict(user_data)
|
38 |
+
|
39 |
+
|
40 |
+
|
41 |
+
# VISUALISATIONS
|
42 |
+
st.title('Visualised Housing Data')
|
43 |
+
|
44 |
+
|
45 |
+
|
46 |
+
# COLOR FUNCTION
|
47 |
+
if user_result[0]==0:
|
48 |
+
color = 'blue'
|
49 |
+
else:
|
50 |
+
color = 'red'
|
51 |
+
|
52 |
+
|
53 |
+
|
54 |
+
# OUTPUT
|
55 |
+
st.subheader('Price of House is : ')
|
56 |
+
st.write(str(user_result))
|
57 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|