RMHalak commited on
Commit
8f827eb
·
verified ·
1 Parent(s): 0a6e3ff

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +50 -42
app.py CHANGED
@@ -41,8 +41,7 @@ max_dict = {
41
  'years_since_renovation': 2014
42
  }
43
 
44
- # Display the predicted price at the top of the app
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
- bedrooms != min_dict['bedrooms'] or
87
- bathrooms != min_dict['bathrooms'] or
88
- sqft_living != min_dict['sqft_living'] or
89
- sqft_lot != min_dict['sqft_lot'] or
90
- floors != min_dict['floors'] or
91
- int(waterfront) != 0 or # Assuming default value for waterfront is 0
92
- view != min_dict['view'] or
93
- condition != min_dict['condition'] or
94
- sqft_above != min_dict['sqft_above'] or
95
- sqft_basement != min_dict['sqft_basement'] or
96
- yr_built != min_dict['yr_built'] or
97
- yr_renovated != min_dict['yr_renovated']):
98
 
99
- new_pred = init_new_pred()
100
- new_pred['bedrooms'] = bedrooms
101
- new_pred['bathrooms'] = bathrooms
102
- new_pred['sqft_living'] = sqft_living
103
- new_pred['sqft_lot'] = sqft_lot
104
- new_pred['floors'] = floors
105
- new_pred['waterfront'] = int(waterfront)
106
- new_pred['view'] = view
107
- new_pred['condition'] = condition
108
- new_pred['sqft_above'] = sqft_above
109
- new_pred['sqft_basement'] = sqft_basement
110
- new_pred['yr_built'] = yr_built
111
- new_pred['yr_renovated'] = yr_renovated
112
- new_pred[f'city_{city}'] = 1
113
-
114
- # Process the prediction
115
- new_pred = pd.DataFrame([new_pred])
116
- new_pred = create_new_features(new_pred)
117
- new_pred = normalize(new_pred)
118
-
119
- # Predict the price
120
- predicted_price = model.predict(new_pred)
 
 
 
121
 
122
  # Display the map in the second column
123
  with col2:
124
  st.subheader('Map')
125
- data = pd.DataFrame({
126
- 'latitude': [47.6097, 47.6205, 47.6762], # Example latitudes
127
- 'longitude': [-122.3331, -122.3493, -122.3198] # Example longitudes
128
- })
129
- st.map(data)
 
 
 
 
 
 
 
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)