RMHalak commited on
Commit
d4d3bd5
·
verified ·
1 Parent(s): 1523bf0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +51 -51
app.py CHANGED
@@ -34,58 +34,58 @@ with col1:
34
  st.subheader('Features')
35
 
36
  with st.container():
37
- st.markdown('<div class="scroll-container">', unsafe_allow_html=True)
38
-
39
- # Create two columns for City and Waterfront
40
- col3, col4 = st.columns(2)
41
-
42
- # City dropdown in the first column
43
- with col3:
44
- city = st.selectbox('City', list(cities_geo.keys()))
45
-
46
- # Waterfront checkbox in the second column
47
- with col4:
48
- waterfront = st.checkbox('Waterfront', value=False)
49
-
50
- # city = st.selectbox('City', list(cities_geo.keys())) # Display city dropdown in the first column
51
- # waterfront = st.checkbox('Waterfront', value=False)
52
- bedrooms = st.slider('Bedrooms', min_value=min_dict['bedrooms'], max_value=max_dict['bedrooms'], value=3)
53
- bathrooms = st.slider('Bathrooms', min_value=min_dict['bathrooms'], max_value=max_dict['bathrooms'], value=2)
54
- sqft_living = st.slider('Square Feet (Living)', min_value=min_dict['sqft_living'], max_value=max_dict['sqft_living'], value=1000)
55
- sqft_lot = st.slider('Square Feet (Lot)', min_value=min_dict['sqft_lot'], max_value=max_dict['sqft_lot'], value=2000)
56
- floors = st.slider('Floors', min_value=min_dict['floors'], max_value=max_dict['floors'], value=1)
57
- view = st.slider('View', min_value=min_dict['view'], max_value=max_dict['view'], value=0)
58
- condition = st.slider('Condition', min_value=min_dict['condition'], max_value=max_dict['condition'], value=3)
59
- sqft_above = st.slider('Square Feet (Above)', min_value=min_dict['sqft_above'], max_value=max_dict['sqft_above'], value=1000)
60
- sqft_basement = st.slider('Square Feet (Basement)', min_value=min_dict['sqft_basement'], max_value=max_dict['sqft_basement'], value=0)
61
- yr_built = st.slider('Year Built', min_value=min_dict['yr_built'], max_value=max_dict['yr_built'], value=2000)
62
- yr_renovated = st.slider('Year Renovated', min_value=min_dict['yr_renovated'], max_value=max_dict['yr_renovated'], value=2010)
63
-
64
- st.markdown('</div>', unsafe_allow_html=True)
65
 
66
- new_pred = init_new_pred()
67
- new_pred['bedrooms'] = bedrooms
68
- new_pred['bathrooms'] = bathrooms
69
- new_pred['sqft_living'] = sqft_living
70
- new_pred['sqft_lot'] = sqft_lot
71
- new_pred['floors'] = floors
72
- new_pred['waterfront'] = int(waterfront)
73
- new_pred['view'] = view
74
- new_pred['condition'] = condition
75
- new_pred['sqft_above'] = sqft_above
76
- new_pred['sqft_basement'] = sqft_basement
77
- new_pred['yr_built'] = yr_built
78
- new_pred['yr_renovated'] = yr_renovated
79
- new_pred[f'city_{city}'] = 1
80
-
81
- # Process the prediction
82
- new_pred = pd.DataFrame([new_pred])
83
- new_pred = create_new_features(new_pred)
84
- new_pred = bucketize(new_pred)
85
- new_pred = normalize(new_pred)
86
-
87
- # Predict the price
88
- predicted_price = model.predict(new_pred)
89
 
90
  # Display the map in the second column
91
  with col2:
 
34
  st.subheader('Features')
35
 
36
  with st.container():
37
+ st.markdown('<div class="scroll-container">', unsafe_allow_html=True)
38
+
39
+ # Create two columns for City and Waterfront
40
+ col3, col4 = st.columns(2)
41
+
42
+ # City dropdown in the first column
43
+ with col3:
44
+ city = st.selectbox('City', list(cities_geo.keys()))
45
+
46
+ # Waterfront checkbox in the second column
47
+ with col4:
48
+ waterfront = st.checkbox('Waterfront', value=False)
49
+
50
+ # city = st.selectbox('City', list(cities_geo.keys())) # Display city dropdown in the first column
51
+ # waterfront = st.checkbox('Waterfront', value=False)
52
+ bedrooms = st.slider('Bedrooms', min_value=min_dict['bedrooms'], max_value=max_dict['bedrooms'], value=3)
53
+ bathrooms = st.slider('Bathrooms', min_value=min_dict['bathrooms'], max_value=max_dict['bathrooms'], value=2)
54
+ sqft_living = st.slider('Square Feet (Living)', min_value=min_dict['sqft_living'], max_value=max_dict['sqft_living'], value=1000)
55
+ sqft_lot = st.slider('Square Feet (Lot)', min_value=min_dict['sqft_lot'], max_value=max_dict['sqft_lot'], value=2000)
56
+ floors = st.slider('Floors', min_value=min_dict['floors'], max_value=max_dict['floors'], value=1)
57
+ view = st.slider('View', min_value=min_dict['view'], max_value=max_dict['view'], value=0)
58
+ condition = st.slider('Condition', min_value=min_dict['condition'], max_value=max_dict['condition'], value=3)
59
+ sqft_above = st.slider('Square Feet (Above)', min_value=min_dict['sqft_above'], max_value=max_dict['sqft_above'], value=1000)
60
+ sqft_basement = st.slider('Square Feet (Basement)', min_value=min_dict['sqft_basement'], max_value=max_dict['sqft_basement'], value=0)
61
+ yr_built = st.slider('Year Built', min_value=min_dict['yr_built'], max_value=max_dict['yr_built'], value=2000)
62
+ yr_renovated = st.slider('Year Renovated', min_value=min_dict['yr_renovated'], max_value=max_dict['yr_renovated'], value=2010)
63
+
64
+ st.markdown('</div>', unsafe_allow_html=True)
65
 
66
+ new_pred = init_new_pred()
67
+ new_pred['bedrooms'] = bedrooms
68
+ new_pred['bathrooms'] = bathrooms
69
+ new_pred['sqft_living'] = sqft_living
70
+ new_pred['sqft_lot'] = sqft_lot
71
+ new_pred['floors'] = floors
72
+ new_pred['waterfront'] = int(waterfront)
73
+ new_pred['view'] = view
74
+ new_pred['condition'] = condition
75
+ new_pred['sqft_above'] = sqft_above
76
+ new_pred['sqft_basement'] = sqft_basement
77
+ new_pred['yr_built'] = yr_built
78
+ new_pred['yr_renovated'] = yr_renovated
79
+ new_pred[f'city_{city}'] = 1
80
+
81
+ # Process the prediction
82
+ new_pred = pd.DataFrame([new_pred])
83
+ new_pred = create_new_features(new_pred)
84
+ new_pred = bucketize(new_pred)
85
+ new_pred = normalize(new_pred)
86
+
87
+ # Predict the price
88
+ predicted_price = model.predict(new_pred)
89
 
90
  # Display the map in the second column
91
  with col2: