RMHalak commited on
Commit
1fedf0d
·
verified ·
1 Parent(s): 0a2e171

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +225 -222
app.py CHANGED
@@ -6,12 +6,12 @@ from utils import create_new_features, normalize, bucketize, init_new_pred
6
 
7
  with open('./trained_model.pkl', 'rb') as file:
8
  model = pickle.load(file)
9
-
10
  with open("./min_dict.json", "r") as f:
11
  min_dict = json.load(f)
12
-
13
  with open("./max_dict.json", "r") as f:
14
  max_dict = json.load(f)
 
 
15
 
16
  st.set_page_config(layout="wide")
17
 
@@ -80,225 +80,228 @@ with col2:
80
  f"<h1 style='font-size: 24px;'>Predicted Price: ${predicted_price[0][0]:,.2f}</h1>",
81
  unsafe_allow_html=True
82
  )
83
- if city == 'Seattle':
84
- map_data = pd.DataFrame({
85
- 'latitude': [47.6097, 47.6205, 47.6762],
86
- 'longitude': [-122.3331, -122.3493, -122.3198]
87
- })
88
- elif city == 'Bellevue':
89
- map_data = pd.DataFrame({
90
- 'latitude': [47.6101, 47.6183],
91
- 'longitude': [-122.2015, -122.2046]
92
- })
93
- elif city == 'Algona':
94
- map_data = pd.DataFrame({
95
- 'latitude': [47.3162],
96
- 'longitude': [-122.2295]
97
- })
98
- elif city == 'Auburn':
99
- map_data = pd.DataFrame({
100
- 'latitude': [47.3073],
101
- 'longitude': [-122.2284]
102
- })
103
- elif city == 'Beaux Arts Village':
104
- map_data = pd.DataFrame({
105
- 'latitude': [47.6141],
106
- 'longitude': [-122.2125]
107
- })
108
- elif city == 'Black Diamond':
109
- map_data = pd.DataFrame({
110
- 'latitude': [47.3465],
111
- 'longitude': [-121.9877]
112
- })
113
- elif city == 'Bothell':
114
- map_data = pd.DataFrame({
115
- 'latitude': [47.7595],
116
- 'longitude': [-122.2056]
117
- })
118
- elif city == 'Burien':
119
- map_data = pd.DataFrame({
120
- 'latitude': [47.4702],
121
- 'longitude': [-122.3359]
122
- })
123
- elif city == 'Carnation':
124
- map_data = pd.DataFrame({
125
- 'latitude': [47.6460],
126
- 'longitude': [-121.9758]
127
- })
128
- elif city == 'Clyde Hill':
129
- map_data = pd.DataFrame({
130
- 'latitude': [47.6330],
131
- 'longitude': [-122.2107]
132
- })
133
- elif city == 'Covington':
134
- map_data = pd.DataFrame({
135
- 'latitude': [47.3765],
136
- 'longitude': [-122.0288]
137
- })
138
- elif city == 'Des Moines':
139
- map_data = pd.DataFrame({
140
- 'latitude': [47.3840],
141
- 'longitude': [-122.3061]
142
- })
143
- elif city == 'Duvall':
144
- map_data = pd.DataFrame({
145
- 'latitude': [47.7332],
146
- 'longitude': [-121.9916]
147
- })
148
- elif city == 'Enumclaw':
149
- map_data = pd.DataFrame({
150
- 'latitude': [47.2059],
151
- 'longitude': [-121.9876]
152
- })
153
- elif city == 'Fall City':
154
- map_data = pd.DataFrame({
155
- 'latitude': [47.5980],
156
- 'longitude': [-121.8896]
157
- })
158
- elif city == 'Federal Way':
159
- map_data = pd.DataFrame({
160
- 'latitude': [47.3220],
161
- 'longitude': [-122.3126]
162
- })
163
- elif city == 'Inglewood-Finn Hill':
164
- map_data = pd.DataFrame({
165
- 'latitude': [47.7338],
166
- 'longitude': [-122.2780]
167
- })
168
- elif city == 'Issaquah':
169
- map_data = pd.DataFrame({
170
- 'latitude': [47.5410],
171
- 'longitude': [-122.0311]
172
- })
173
- elif city == 'Kenmore':
174
- map_data = pd.DataFrame({
175
- 'latitude': [47.7557],
176
- 'longitude': [-122.2416]
177
- })
178
- elif city == 'Kent':
179
- map_data = pd.DataFrame({
180
- 'latitude': [47.3809],
181
- 'longitude': [-122.2348]
182
- })
183
- elif city == 'Kirkland':
184
- map_data = pd.DataFrame({
185
- 'latitude': [47.6810],
186
- 'longitude': [-122.2087]
187
- })
188
- elif city == 'Lake Forest Park':
189
- map_data = pd.DataFrame({
190
- 'latitude': [47.7318],
191
- 'longitude': [-122.2764]
192
- })
193
- elif city == 'Maple Valley':
194
- map_data = pd.DataFrame({
195
- 'latitude': [47.3610],
196
- 'longitude': [-122.0240]
197
- })
198
- elif city == 'Medina':
199
- map_data = pd.DataFrame({
200
- 'latitude': [47.6357],
201
- 'longitude': [-122.2169]
202
- })
203
- elif city == 'Mercer Island':
204
- map_data = pd.DataFrame({
205
- 'latitude': [47.5703],
206
- 'longitude': [-122.2264]
207
- })
208
- elif city == 'Milton':
209
- map_data = pd.DataFrame({
210
- 'latitude': [47.2335],
211
- 'longitude': [-122.2730]
212
- })
213
- elif city == 'Newcastle':
214
- map_data = pd.DataFrame({
215
- 'latitude': [47.5477],
216
- 'longitude': [-122.1711]
217
- })
218
- elif city == 'Normandy Park':
219
- map_data = pd.DataFrame({
220
- 'latitude': [47.4051],
221
- 'longitude': [-122.3376]
222
- })
223
- elif city == 'North Bend':
224
- map_data = pd.DataFrame({
225
- 'latitude': [47.4904],
226
- 'longitude': [-121.7852]
227
- })
228
- elif city == 'Pacific':
229
- map_data = pd.DataFrame({
230
- 'latitude': [47.3197],
231
- 'longitude': [-122.2786]
232
- })
233
- elif city == 'Preston':
234
- map_data = pd.DataFrame({
235
- 'latitude': [47.5420],
236
- 'longitude': [-121.9214]
237
- })
238
- elif city == 'Ravensdale':
239
- map_data = pd.DataFrame({
240
- 'latitude': [47.3485],
241
- 'longitude': [-121.9807]
242
- })
243
- elif city == 'Redmond':
244
- map_data = pd.DataFrame({
245
- 'latitude': [47.6734],
246
- 'longitude': [-122.1215]
247
- })
248
- elif city == 'Renton':
249
- map_data = pd.DataFrame({
250
- 'latitude': [47.4829],
251
- 'longitude': [-122.2170]
252
- })
253
- elif city == 'Sammamish':
254
- map_data = pd.DataFrame({
255
- 'latitude': [47.6162],
256
- 'longitude': [-122.0394]
257
- })
258
- elif city == 'SeaTac':
259
- map_data = pd.DataFrame({
260
- 'latitude': [47.4484],
261
- 'longitude': [-122.3085]
262
- })
263
- elif city == 'Shoreline':
264
- map_data = pd.DataFrame({
265
- 'latitude': [47.7554],
266
- 'longitude': [-122.3410]
267
- })
268
- elif city == 'Skykomish':
269
- map_data = pd.DataFrame({
270
- 'latitude': [47.7054],
271
- 'longitude': [-121.4848]
272
- })
273
- elif city == 'Snoqualmie':
274
- map_data = pd.DataFrame({
275
- 'latitude': [47.5410],
276
- 'longitude': [-121.8340]
277
- })
278
- elif city == 'Snoqualmie Pass':
279
- map_data = pd.DataFrame({
280
- 'latitude': [47.4286],
281
- 'longitude': [-121.4420]
282
- })
283
- elif city == 'Tukwila':
284
- map_data = pd.DataFrame({
285
- 'latitude': [47.4835],
286
- 'longitude': [-122.2585]
287
- })
288
- elif city == 'Vashon':
289
- map_data = pd.DataFrame({
290
- 'latitude': [47.4337],
291
- 'longitude': [-122.4660]
292
- })
293
- elif city == 'Woodinville':
294
- map_data = pd.DataFrame({
295
- 'latitude': [47.7524],
296
- 'longitude': [-122.1576]
297
- })
298
- elif city == 'Yarrow Point':
299
- map_data = pd.DataFrame({
300
- 'latitude': [47.6348],
301
- 'longitude': [-122.2218]
302
- })
 
 
 
303
 
304
  st.map(map_data, zoom=11)
 
6
 
7
  with open('./trained_model.pkl', 'rb') as file:
8
  model = pickle.load(file)
 
9
  with open("./min_dict.json", "r") as f:
10
  min_dict = json.load(f)
 
11
  with open("./max_dict.json", "r") as f:
12
  max_dict = json.load(f)
13
+ with open("./cities_geo.json", "r") as f:
14
+ cities_geo = json.load(f)
15
 
16
  st.set_page_config(layout="wide")
17
 
 
80
  f"<h1 style='font-size: 24px;'>Predicted Price: ${predicted_price[0][0]:,.2f}</h1>",
81
  unsafe_allow_html=True
82
  )
83
+
84
+ map_data = cities_geo[pd.DataFrame(city)]
85
+
86
+ # if city == 'Seattle':
87
+ # map_data = pd.DataFrame({
88
+ # 'latitude': [47.6097, 47.6205, 47.6762],
89
+ # 'longitude': [-122.3331, -122.3493, -122.3198]
90
+ # })
91
+ # elif city == 'Bellevue':
92
+ # map_data = pd.DataFrame({
93
+ # 'latitude': [47.6101, 47.6183],
94
+ # 'longitude': [-122.2015, -122.2046]
95
+ # })
96
+ # elif city == 'Algona':
97
+ # map_data = pd.DataFrame({
98
+ # 'latitude': [47.3162],
99
+ # 'longitude': [-122.2295]
100
+ # })
101
+ # elif city == 'Auburn':
102
+ # map_data = pd.DataFrame({
103
+ # 'latitude': [47.3073],
104
+ # 'longitude': [-122.2284]
105
+ # })
106
+ # elif city == 'Beaux Arts Village':
107
+ # map_data = pd.DataFrame({
108
+ # 'latitude': [47.6141],
109
+ # 'longitude': [-122.2125]
110
+ # })
111
+ # elif city == 'Black Diamond':
112
+ # map_data = pd.DataFrame({
113
+ # 'latitude': [47.3465],
114
+ # 'longitude': [-121.9877]
115
+ # })
116
+ # elif city == 'Bothell':
117
+ # map_data = pd.DataFrame({
118
+ # 'latitude': [47.7595],
119
+ # 'longitude': [-122.2056]
120
+ # })
121
+ # elif city == 'Burien':
122
+ # map_data = pd.DataFrame({
123
+ # 'latitude': [47.4702],
124
+ # 'longitude': [-122.3359]
125
+ # })
126
+ # elif city == 'Carnation':
127
+ # map_data = pd.DataFrame({
128
+ # 'latitude': [47.6460],
129
+ # 'longitude': [-121.9758]
130
+ # })
131
+ # elif city == 'Clyde Hill':
132
+ # map_data = pd.DataFrame({
133
+ # 'latitude': [47.6330],
134
+ # 'longitude': [-122.2107]
135
+ # })
136
+ # elif city == 'Covington':
137
+ # map_data = pd.DataFrame({
138
+ # 'latitude': [47.3765],
139
+ # 'longitude': [-122.0288]
140
+ # })
141
+ # elif city == 'Des Moines':
142
+ # map_data = pd.DataFrame({
143
+ # 'latitude': [47.3840],
144
+ # 'longitude': [-122.3061]
145
+ # })
146
+ # elif city == 'Duvall':
147
+ # map_data = pd.DataFrame({
148
+ # 'latitude': [47.7332],
149
+ # 'longitude': [-121.9916]
150
+ # })
151
+ # elif city == 'Enumclaw':
152
+ # map_data = pd.DataFrame({
153
+ # 'latitude': [47.2059],
154
+ # 'longitude': [-121.9876]
155
+ # })
156
+ # elif city == 'Fall City':
157
+ # map_data = pd.DataFrame({
158
+ # 'latitude': [47.5980],
159
+ # 'longitude': [-121.8896]
160
+ # })
161
+ # elif city == 'Federal Way':
162
+ # map_data = pd.DataFrame({
163
+ # 'latitude': [47.3220],
164
+ # 'longitude': [-122.3126]
165
+ # })
166
+ # elif city == 'Inglewood-Finn Hill':
167
+ # map_data = pd.DataFrame({
168
+ # 'latitude': [47.7338],
169
+ # 'longitude': [-122.2780]
170
+ # })
171
+ # elif city == 'Issaquah':
172
+ # map_data = pd.DataFrame({
173
+ # 'latitude': [47.5410],
174
+ # 'longitude': [-122.0311]
175
+ # })
176
+ # elif city == 'Kenmore':
177
+ # map_data = pd.DataFrame({
178
+ # 'latitude': [47.7557],
179
+ # 'longitude': [-122.2416]
180
+ # })
181
+ # elif city == 'Kent':
182
+ # map_data = pd.DataFrame({
183
+ # 'latitude': [47.3809],
184
+ # 'longitude': [-122.2348]
185
+ # })
186
+ # elif city == 'Kirkland':
187
+ # map_data = pd.DataFrame({
188
+ # 'latitude': [47.6810],
189
+ # 'longitude': [-122.2087]
190
+ # })
191
+ # elif city == 'Lake Forest Park':
192
+ # map_data = pd.DataFrame({
193
+ # 'latitude': [47.7318],
194
+ # 'longitude': [-122.2764]
195
+ # })
196
+ # elif city == 'Maple Valley':
197
+ # map_data = pd.DataFrame({
198
+ # 'latitude': [47.3610],
199
+ # 'longitude': [-122.0240]
200
+ # })
201
+ # elif city == 'Medina':
202
+ # map_data = pd.DataFrame({
203
+ # 'latitude': [47.6357],
204
+ # 'longitude': [-122.2169]
205
+ # })
206
+ # elif city == 'Mercer Island':
207
+ # map_data = pd.DataFrame({
208
+ # 'latitude': [47.5703],
209
+ # 'longitude': [-122.2264]
210
+ # })
211
+ # elif city == 'Milton':
212
+ # map_data = pd.DataFrame({
213
+ # 'latitude': [47.2335],
214
+ # 'longitude': [-122.2730]
215
+ # })
216
+ # elif city == 'Newcastle':
217
+ # map_data = pd.DataFrame({
218
+ # 'latitude': [47.5477],
219
+ # 'longitude': [-122.1711]
220
+ # })
221
+ # elif city == 'Normandy Park':
222
+ # map_data = pd.DataFrame({
223
+ # 'latitude': [47.4051],
224
+ # 'longitude': [-122.3376]
225
+ # })
226
+ # elif city == 'North Bend':
227
+ # map_data = pd.DataFrame({
228
+ # 'latitude': [47.4904],
229
+ # 'longitude': [-121.7852]
230
+ # })
231
+ # elif city == 'Pacific':
232
+ # map_data = pd.DataFrame({
233
+ # 'latitude': [47.3197],
234
+ # 'longitude': [-122.2786]
235
+ # })
236
+ # elif city == 'Preston':
237
+ # map_data = pd.DataFrame({
238
+ # 'latitude': [47.5420],
239
+ # 'longitude': [-121.9214]
240
+ # })
241
+ # elif city == 'Ravensdale':
242
+ # map_data = pd.DataFrame({
243
+ # 'latitude': [47.3485],
244
+ # 'longitude': [-121.9807]
245
+ # })
246
+ # elif city == 'Redmond':
247
+ # map_data = pd.DataFrame({
248
+ # 'latitude': [47.6734],
249
+ # 'longitude': [-122.1215]
250
+ # })
251
+ # elif city == 'Renton':
252
+ # map_data = pd.DataFrame({
253
+ # 'latitude': [47.4829],
254
+ # 'longitude': [-122.2170]
255
+ # })
256
+ # elif city == 'Sammamish':
257
+ # map_data = pd.DataFrame({
258
+ # 'latitude': [47.6162],
259
+ # 'longitude': [-122.0394]
260
+ # })
261
+ # elif city == 'SeaTac':
262
+ # map_data = pd.DataFrame({
263
+ # 'latitude': [47.4484],
264
+ # 'longitude': [-122.3085]
265
+ # })
266
+ # elif city == 'Shoreline':
267
+ # map_data = pd.DataFrame({
268
+ # 'latitude': [47.7554],
269
+ # 'longitude': [-122.3410]
270
+ # })
271
+ # elif city == 'Skykomish':
272
+ # map_data = pd.DataFrame({
273
+ # 'latitude': [47.7054],
274
+ # 'longitude': [-121.4848]
275
+ # })
276
+ # elif city == 'Snoqualmie':
277
+ # map_data = pd.DataFrame({
278
+ # 'latitude': [47.5410],
279
+ # 'longitude': [-121.8340]
280
+ # })
281
+ # elif city == 'Snoqualmie Pass':
282
+ # map_data = pd.DataFrame({
283
+ # 'latitude': [47.4286],
284
+ # 'longitude': [-121.4420]
285
+ # })
286
+ # elif city == 'Tukwila':
287
+ # map_data = pd.DataFrame({
288
+ # 'latitude': [47.4835],
289
+ # 'longitude': [-122.2585]
290
+ # })
291
+ # elif city == 'Vashon':
292
+ # map_data = pd.DataFrame({
293
+ # 'latitude': [47.4337],
294
+ # 'longitude': [-122.4660]
295
+ # })
296
+ # elif city == 'Woodinville':
297
+ # map_data = pd.DataFrame({
298
+ # 'latitude': [47.7524],
299
+ # 'longitude': [-122.1576]
300
+ # })
301
+ # elif city == 'Yarrow Point':
302
+ # map_data = pd.DataFrame({
303
+ # 'latitude': [47.6348],
304
+ # 'longitude': [-122.2218]
305
+ # })
306
 
307
  st.map(map_data, zoom=11)