Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
@@ -1,54 +1,7 @@
|
|
1 |
import streamlit as st
|
2 |
import pandas as pd
|
3 |
import pickle
|
4 |
-
from utils import create_new_features, normalize
|
5 |
-
|
6 |
-
min_dict = {'bedrooms': 0,
|
7 |
-
'bathrooms': 0,
|
8 |
-
'sqft_living': 370,
|
9 |
-
'sqft_lot': 638,
|
10 |
-
'floors': 1,
|
11 |
-
'waterfront': 0,
|
12 |
-
'view': 0,
|
13 |
-
'condition': 1,
|
14 |
-
'sqft_above': 370,
|
15 |
-
'sqft_basement': 0,
|
16 |
-
'yr_built': 1900,
|
17 |
-
'yr_renovated': 0,
|
18 |
-
'house_age': 0,
|
19 |
-
'years_since_renovation': 0}
|
20 |
-
|
21 |
-
max_dict = {'bedrooms': 9,
|
22 |
-
'bathrooms': 8,
|
23 |
-
'sqft_living': 13540,
|
24 |
-
'sqft_lot': 1074218,
|
25 |
-
'floors': 3,
|
26 |
-
'waterfront': 1,
|
27 |
-
'view': 4,
|
28 |
-
'condition': 5,
|
29 |
-
'sqft_above': 9410,
|
30 |
-
'sqft_basement': 4820,
|
31 |
-
'yr_built': 2014,
|
32 |
-
'yr_renovated': 2014,
|
33 |
-
'house_age': 114,
|
34 |
-
'years_since_renovation': 2014}
|
35 |
-
|
36 |
-
columns = ['bedrooms', 'bathrooms', 'sqft_living', 'sqft_lot', 'floors',
|
37 |
-
'waterfront', 'view', 'condition', 'sqft_above', 'sqft_basement',
|
38 |
-
'yr_built', 'yr_renovated', 'house_age', 'years_since_renovation',
|
39 |
-
'has_basement', 'city_Algona', 'city_Auburn', 'city_Beaux Arts Village',
|
40 |
-
'city_Bellevue', 'city_Black Diamond', 'city_Bothell', 'city_Burien',
|
41 |
-
'city_Carnation', 'city_Clyde Hill', 'city_Covington',
|
42 |
-
'city_Des Moines', 'city_Duvall', 'city_Enumclaw', 'city_Fall City',
|
43 |
-
'city_Federal Way', 'city_Inglewood-Finn Hill', 'city_Issaquah',
|
44 |
-
'city_Kenmore', 'city_Kent', 'city_Kirkland', 'city_Lake Forest Park',
|
45 |
-
'city_Maple Valley', 'city_Medina', 'city_Mercer Island', 'city_Milton',
|
46 |
-
'city_Newcastle', 'city_Normandy Park', 'city_North Bend',
|
47 |
-
'city_Pacific', 'city_Preston', 'city_Ravensdale', 'city_Redmond',
|
48 |
-
'city_Renton', 'city_Sammamish', 'city_SeaTac', 'city_Seattle',
|
49 |
-
'city_Shoreline', 'city_Skykomish', 'city_Snoqualmie',
|
50 |
-
'city_Snoqualmie Pass', 'city_Tukwila', 'city_Vashon',
|
51 |
-
'city_Woodinville', 'city_Yarrow Point']
|
52 |
|
53 |
with open('./trained_model.pkl', 'rb') as file:
|
54 |
model = pickle.load(file)
|
@@ -56,9 +9,7 @@ with open('./trained_model.pkl', 'rb') as file:
|
|
56 |
new_pred = st.text_area('Enter text')
|
57 |
|
58 |
if new_pred:
|
59 |
-
new_pred =
|
60 |
-
new_pred['date'] = pd.to_datetime('2014-07-10') # do not change
|
61 |
-
|
62 |
new_pred['bedrooms'] = 5
|
63 |
new_pred['bathrooms'] = 3
|
64 |
new_pred['sqft_living'] = 10000
|
@@ -75,8 +26,7 @@ if new_pred:
|
|
75 |
new_pred = pd.DataFrame([new_pred])
|
76 |
|
77 |
new_pred = create_new_features(new_pred)
|
78 |
-
|
79 |
-
new_pred[col] = normalize(new_pred, col, min_dict, max_dict)
|
80 |
|
81 |
predicted_price = model.predict(new_pred)
|
82 |
st.json(predicted_price[0][0])
|
|
|
1 |
import streamlit as st
|
2 |
import pandas as pd
|
3 |
import pickle
|
4 |
+
from utils import create_new_features, normalize, init_new_pred
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
|
6 |
with open('./trained_model.pkl', 'rb') as file:
|
7 |
model = pickle.load(file)
|
|
|
9 |
new_pred = st.text_area('Enter text')
|
10 |
|
11 |
if new_pred:
|
12 |
+
new_pred = init_new_pred()
|
|
|
|
|
13 |
new_pred['bedrooms'] = 5
|
14 |
new_pred['bathrooms'] = 3
|
15 |
new_pred['sqft_living'] = 10000
|
|
|
26 |
new_pred = pd.DataFrame([new_pred])
|
27 |
|
28 |
new_pred = create_new_features(new_pred)
|
29 |
+
new_pred = normalize(new_pred)
|
|
|
30 |
|
31 |
predicted_price = model.predict(new_pred)
|
32 |
st.json(predicted_price[0][0])
|