Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
@@ -41,8 +41,7 @@ max_dict = {
|
|
41 |
'years_since_renovation': 2014
|
42 |
}
|
43 |
|
44 |
-
|
45 |
-
price_placeholder.write(f"Predicted Price: ${predicted_price[0][0]:,.2f}")
|
46 |
|
47 |
# Create two columns: one for the city and one for the map
|
48 |
col1, col2 = st.columns([1, 2]) # Adjust the width ratios as needed
|
@@ -82,48 +81,57 @@ with col1:
|
|
82 |
yr_built = st.slider('Year Built', min_value=min_dict['yr_built'], max_value=max_dict['yr_built'], value=min_dict['yr_built'])
|
83 |
yr_renovated = st.slider('Year Renovated', min_value=min_dict['yr_renovated'], max_value=max_dict['yr_renovated'], value=min_dict['yr_renovated'])
|
84 |
|
85 |
-
if (city != 'Algona' or # Assuming Algona as the default value
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
|
|
|
|
|
|
121 |
|
122 |
# Display the map in the second column
|
123 |
with col2:
|
124 |
st.subheader('Map')
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
41 |
'years_since_renovation': 2014
|
42 |
}
|
43 |
|
44 |
+
|
|
|
45 |
|
46 |
# Create two columns: one for the city and one for the map
|
47 |
col1, col2 = st.columns([1, 2]) # Adjust the width ratios as needed
|
|
|
81 |
yr_built = st.slider('Year Built', min_value=min_dict['yr_built'], max_value=max_dict['yr_built'], value=min_dict['yr_built'])
|
82 |
yr_renovated = st.slider('Year Renovated', min_value=min_dict['yr_renovated'], max_value=max_dict['yr_renovated'], value=min_dict['yr_renovated'])
|
83 |
|
84 |
+
# if (city != 'Algona' or # Assuming Algona as the default value
|
85 |
+
# bedrooms != min_dict['bedrooms'] or
|
86 |
+
# bathrooms != min_dict['bathrooms'] or
|
87 |
+
# sqft_living != min_dict['sqft_living'] or
|
88 |
+
# sqft_lot != min_dict['sqft_lot'] or
|
89 |
+
# floors != min_dict['floors'] or
|
90 |
+
# int(waterfront) != 0 or # Assuming default value for waterfront is 0
|
91 |
+
# view != min_dict['view'] or
|
92 |
+
# condition != min_dict['condition'] or
|
93 |
+
# sqft_above != min_dict['sqft_above'] or
|
94 |
+
# sqft_basement != min_dict['sqft_basement'] or
|
95 |
+
# yr_built != min_dict['yr_built'] or
|
96 |
+
# yr_renovated != min_dict['yr_renovated']):
|
97 |
|
98 |
+
new_pred = init_new_pred()
|
99 |
+
new_pred['bedrooms'] = bedrooms
|
100 |
+
new_pred['bathrooms'] = bathrooms
|
101 |
+
new_pred['sqft_living'] = sqft_living
|
102 |
+
new_pred['sqft_lot'] = sqft_lot
|
103 |
+
new_pred['floors'] = floors
|
104 |
+
new_pred['waterfront'] = int(waterfront)
|
105 |
+
new_pred['view'] = view
|
106 |
+
new_pred['condition'] = condition
|
107 |
+
new_pred['sqft_above'] = sqft_above
|
108 |
+
new_pred['sqft_basement'] = sqft_basement
|
109 |
+
new_pred['yr_built'] = yr_built
|
110 |
+
new_pred['yr_renovated'] = yr_renovated
|
111 |
+
new_pred[f'city_{city}'] = 1
|
112 |
+
|
113 |
+
# Process the prediction
|
114 |
+
new_pred = pd.DataFrame([new_pred])
|
115 |
+
new_pred = create_new_features(new_pred)
|
116 |
+
new_pred = normalize(new_pred)
|
117 |
+
|
118 |
+
# Predict the price
|
119 |
+
predicted_price = model.predict(new_pred)
|
120 |
+
|
121 |
+
# Display the predicted price at the top of the app
|
122 |
+
price_placeholder.write(f"Predicted Price: ${predicted_price[0][0]:,.2f}")
|
123 |
|
124 |
# Display the map in the second column
|
125 |
with col2:
|
126 |
st.subheader('Map')
|
127 |
+
if city == 'Algona':
|
128 |
+
map_data = pd.DataFrame({
|
129 |
+
'latitude': [47.6097, 47.6205, 47.6762],
|
130 |
+
'longitude': [-122.3331, -122.3493, -122.3198]
|
131 |
+
})
|
132 |
+
elif city == 'Auburn':
|
133 |
+
map_data = pd.DataFrame({
|
134 |
+
'latitude': [47.6101, 47.6183],
|
135 |
+
'longitude': [-122.2015, -122.2046]
|
136 |
+
})
|
137 |
+
st.map(map_data)
|