RMHalak commited on
Commit
46440c4
·
verified ·
1 Parent(s): 8f827eb

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +223 -16
app.py CHANGED
@@ -40,18 +40,14 @@ max_dict = {
40
  'house_age': 114,
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
48
 
49
  # Display city dropdown in the first column
50
  with col1:
51
- # Placeholder for displaying the predicted price at the top
52
- price_placeholder = st.empty()
53
 
54
- st.subheader('City Selection')
55
  city = st.selectbox(
56
  'Select City',
57
  ['Algona', 'Auburn', 'Beaux Arts Village', 'Bellevue',
@@ -64,10 +60,7 @@ with col1:
64
  'Renton', 'Sammamish', 'SeaTac', 'Seattle', 'Shoreline',
65
  'Skykomish', 'Snoqualmie', 'Snoqualmie Pass', 'Tukwila', 'Vashon',
66
  'Woodinville', 'Yarrow Point'],
67
-
68
  )
69
-
70
- # Create sliders for each item in the dictionaries
71
  bedrooms = st.slider('Bedrooms', min_value=min_dict['bedrooms'], max_value=max_dict['bedrooms'], value=min_dict['bedrooms'])
72
  bathrooms = st.slider('Bathrooms', min_value=min_dict['bathrooms'], max_value=max_dict['bathrooms'], value=min_dict['bathrooms'])
73
  sqft_living = st.slider('Square Feet (Living)', min_value=min_dict['sqft_living'], max_value=max_dict['sqft_living'], value=min_dict['sqft_living'])
@@ -118,20 +111,234 @@ with col1:
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)
 
 
 
 
 
 
 
40
  'house_age': 114,
41
  'years_since_renovation': 2014
42
  }
 
 
43
 
44
  # Create two columns: one for the city and one for the map
45
  col1, col2 = st.columns([1, 2]) # Adjust the width ratios as needed
46
 
47
  # Display city dropdown in the first column
48
  with col1:
49
+ st.subheader('Features')
 
50
 
 
51
  city = st.selectbox(
52
  'Select City',
53
  ['Algona', 'Auburn', 'Beaux Arts Village', 'Bellevue',
 
60
  'Renton', 'Sammamish', 'SeaTac', 'Seattle', 'Shoreline',
61
  'Skykomish', 'Snoqualmie', 'Snoqualmie Pass', 'Tukwila', 'Vashon',
62
  'Woodinville', 'Yarrow Point'],
 
63
  )
 
 
64
  bedrooms = st.slider('Bedrooms', min_value=min_dict['bedrooms'], max_value=max_dict['bedrooms'], value=min_dict['bedrooms'])
65
  bathrooms = st.slider('Bathrooms', min_value=min_dict['bathrooms'], max_value=max_dict['bathrooms'], value=min_dict['bathrooms'])
66
  sqft_living = st.slider('Square Feet (Living)', min_value=min_dict['sqft_living'], max_value=max_dict['sqft_living'], value=min_dict['sqft_living'])
 
111
  # Predict the price
112
  predicted_price = model.predict(new_pred)
113
 
 
 
 
114
  # Display the map in the second column
115
  with col2:
116
  st.subheader('Map')
117
+ if city == 'Seattle':
118
+ map_data = pd.DataFrame({
119
+ 'latitude': [47.6097, 47.6205, 47.6762],
120
+ 'longitude': [-122.3331, -122.3493, -122.3198]
121
+ })
122
+ elif city == 'Bellevue':
123
+ map_data = pd.DataFrame({
124
+ 'latitude': [47.6101, 47.6183],
125
+ 'longitude': [-122.2015, -122.2046]
126
+ })
127
+ elif city == 'Algona':
128
  map_data = pd.DataFrame({
129
+ 'latitude': [47.3162],
130
+ 'longitude': [-122.2295]
131
  })
132
  elif city == 'Auburn':
133
  map_data = pd.DataFrame({
134
+ 'latitude': [47.3073],
135
+ 'longitude': [-122.2284]
136
+ })
137
+ elif city == 'Beaux Arts Village':
138
+ map_data = pd.DataFrame({
139
+ 'latitude': [47.6141],
140
+ 'longitude': [-122.2125]
141
+ })
142
+ elif city == 'Black Diamond':
143
+ map_data = pd.DataFrame({
144
+ 'latitude': [47.3465],
145
+ 'longitude': [-121.9877]
146
+ })
147
+ elif city == 'Bothell':
148
+ map_data = pd.DataFrame({
149
+ 'latitude': [47.7595],
150
+ 'longitude': [-122.2056]
151
+ })
152
+ elif city == 'Burien':
153
+ map_data = pd.DataFrame({
154
+ 'latitude': [47.4702],
155
+ 'longitude': [-122.3359]
156
+ })
157
+ elif city == 'Carnation':
158
+ map_data = pd.DataFrame({
159
+ 'latitude': [47.6460],
160
+ 'longitude': [-121.9758]
161
+ })
162
+ elif city == 'Clyde Hill':
163
+ map_data = pd.DataFrame({
164
+ 'latitude': [47.6330],
165
+ 'longitude': [-122.2107]
166
  })
167
+ elif city == 'Covington':
168
+ map_data = pd.DataFrame({
169
+ 'latitude': [47.3765],
170
+ 'longitude': [-122.0288]
171
+ })
172
+ elif city == 'Des Moines':
173
+ map_data = pd.DataFrame({
174
+ 'latitude': [47.3840],
175
+ 'longitude': [-122.3061]
176
+ })
177
+ elif city == 'Duvall':
178
+ map_data = pd.DataFrame({
179
+ 'latitude': [47.7332],
180
+ 'longitude': [-121.9916]
181
+ })
182
+ elif city == 'Enumclaw':
183
+ map_data = pd.DataFrame({
184
+ 'latitude': [47.2059],
185
+ 'longitude': [-121.9876]
186
+ })
187
+ elif city == 'Fall City':
188
+ map_data = pd.DataFrame({
189
+ 'latitude': [47.5980],
190
+ 'longitude': [-121.8896]
191
+ })
192
+ elif city == 'Federal Way':
193
+ map_data = pd.DataFrame({
194
+ 'latitude': [47.3220],
195
+ 'longitude': [-122.3126]
196
+ })
197
+ elif city == 'Inglewood-Finn Hill':
198
+ map_data = pd.DataFrame({
199
+ 'latitude': [47.7338],
200
+ 'longitude': [-122.2780]
201
+ })
202
+ elif city == 'Issaquah':
203
+ map_data = pd.DataFrame({
204
+ 'latitude': [47.5410],
205
+ 'longitude': [-122.0311]
206
+ })
207
+ elif city == 'Kenmore':
208
+ map_data = pd.DataFrame({
209
+ 'latitude': [47.7557],
210
+ 'longitude': [-122.2416]
211
+ })
212
+ elif city == 'Kent':
213
+ map_data = pd.DataFrame({
214
+ 'latitude': [47.3809],
215
+ 'longitude': [-122.2348]
216
+ })
217
+ elif city == 'Kirkland':
218
+ map_data = pd.DataFrame({
219
+ 'latitude': [47.6810],
220
+ 'longitude': [-122.2087]
221
+ })
222
+ elif city == 'Lake Forest Park':
223
+ map_data = pd.DataFrame({
224
+ 'latitude': [47.7318],
225
+ 'longitude': [-122.2764]
226
+ })
227
+ elif city == 'Maple Valley':
228
+ map_data = pd.DataFrame({
229
+ 'latitude': [47.3610],
230
+ 'longitude': [-122.0240]
231
+ })
232
+ elif city == 'Medina':
233
+ map_data = pd.DataFrame({
234
+ 'latitude': [47.6357],
235
+ 'longitude': [-122.2169]
236
+ })
237
+ elif city == 'Mercer Island':
238
+ map_data = pd.DataFrame({
239
+ 'latitude': [47.5703],
240
+ 'longitude': [-122.2264]
241
+ })
242
+ elif city == 'Milton':
243
+ map_data = pd.DataFrame({
244
+ 'latitude': [47.2335],
245
+ 'longitude': [-122.2730]
246
+ })
247
+ elif city == 'Newcastle':
248
+ map_data = pd.DataFrame({
249
+ 'latitude': [47.5477],
250
+ 'longitude': [-122.1711]
251
+ })
252
+ elif city == 'Normandy Park':
253
+ map_data = pd.DataFrame({
254
+ 'latitude': [47.4051],
255
+ 'longitude': [-122.3376]
256
+ })
257
+ elif city == 'North Bend':
258
+ map_data = pd.DataFrame({
259
+ 'latitude': [47.4904],
260
+ 'longitude': [-121.7852]
261
+ })
262
+ elif city == 'Pacific':
263
+ map_data = pd.DataFrame({
264
+ 'latitude': [47.3197],
265
+ 'longitude': [-122.2786]
266
+ })
267
+ elif city == 'Preston':
268
+ map_data = pd.DataFrame({
269
+ 'latitude': [47.5420],
270
+ 'longitude': [-121.9214]
271
+ })
272
+ elif city == 'Ravensdale':
273
+ map_data = pd.DataFrame({
274
+ 'latitude': [47.3485],
275
+ 'longitude': [-121.9807]
276
+ })
277
+ elif city == 'Redmond':
278
+ map_data = pd.DataFrame({
279
+ 'latitude': [47.6734],
280
+ 'longitude': [-122.1215]
281
+ })
282
+ elif city == 'Renton':
283
+ map_data = pd.DataFrame({
284
+ 'latitude': [47.4829],
285
+ 'longitude': [-122.2170]
286
+ })
287
+ elif city == 'Sammamish':
288
+ map_data = pd.DataFrame({
289
+ 'latitude': [47.6162],
290
+ 'longitude': [-122.0394]
291
+ })
292
+ elif city == 'SeaTac':
293
+ map_data = pd.DataFrame({
294
+ 'latitude': [47.4484],
295
+ 'longitude': [-122.3085]
296
+ })
297
+ elif city == 'Shoreline':
298
+ map_data = pd.DataFrame({
299
+ 'latitude': [47.7554],
300
+ 'longitude': [-122.3410]
301
+ })
302
+ elif city == 'Skykomish':
303
+ map_data = pd.DataFrame({
304
+ 'latitude': [47.7054],
305
+ 'longitude': [-121.4848]
306
+ })
307
+ elif city == 'Snoqualmie':
308
+ map_data = pd.DataFrame({
309
+ 'latitude': [47.5410],
310
+ 'longitude': [-121.8340]
311
+ })
312
+ elif city == 'Snoqualmie Pass':
313
+ map_data = pd.DataFrame({
314
+ 'latitude': [47.4286],
315
+ 'longitude': [-121.4420]
316
+ })
317
+ elif city == 'Tukwila':
318
+ map_data = pd.DataFrame({
319
+ 'latitude': [47.4835],
320
+ 'longitude': [-122.2585]
321
+ })
322
+ elif city == 'Vashon':
323
+ map_data = pd.DataFrame({
324
+ 'latitude': [47.4337],
325
+ 'longitude': [-122.4660]
326
+ })
327
+ elif city == 'Woodinville':
328
+ map_data = pd.DataFrame({
329
+ 'latitude': [47.7524],
330
+ 'longitude': [-122.1576]
331
+ })
332
+ elif city == 'Yarrow Point':
333
+ map_data = pd.DataFrame({
334
+ 'latitude': [47.6348],
335
+ 'longitude': [-122.2218]
336
+ })
337
+
338
  st.map(map_data)
339
+
340
+ # Placeholder for displaying the predicted price at the top
341
+ price_placeholder = st.empty()
342
+
343
+ # Display the predicted price at the top of the app
344
+ price_placeholder.write(f"Predicted Price: ${predicted_price[0][0]:,.2f}")