RMHalak commited on
Commit
a651923
·
verified ·
1 Parent(s): 1ec73eb

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -23
app.py CHANGED
@@ -6,7 +6,7 @@ from utils import create_new_features, normalize, bucketize, init_new_pred
6
 
7
  st.set_page_config(layout="wide")
8
 
9
- # load model and files
10
  with open('./trained_model.pkl', 'rb') as file:
11
  model = pickle.load(file)
12
  with open("./min_dict.json", "r") as f:
@@ -22,19 +22,20 @@ col1, col2 = st.columns([1, 2]) # Adjust the width ratios as needed
22
  with col1:
23
  st.subheader('Features')
24
 
25
- city = st.selectbox('City', list(cities_geo.keys())) # Display city dropdown in the first column
26
- waterfront = st.checkbox('Waterfront', value=False)
27
- bedrooms = st.slider('Bedrooms', min_value=min_dict['bedrooms'], max_value=max_dict['bedrooms'], value=3)
28
- bathrooms = st.slider('Bathrooms', min_value=min_dict['bathrooms'], max_value=max_dict['bathrooms'], value=2)
29
- sqft_living = st.slider('Square Feet (Living)', min_value=min_dict['sqft_living'], max_value=max_dict['sqft_living'], value=1000)
30
- sqft_lot = st.slider('Square Feet (Lot)', min_value=min_dict['sqft_lot'], max_value=max_dict['sqft_lot'], value=2000)
31
- floors = st.slider('Floors', min_value=min_dict['floors'], max_value=max_dict['floors'], value=1)
32
- view = st.slider('View', min_value=min_dict['view'], max_value=max_dict['view'], value=0)
33
- condition = st.slider('Condition', min_value=min_dict['condition'], max_value=max_dict['condition'], value=3)
34
- sqft_above = st.slider('Square Feet (Above)', min_value=min_dict['sqft_above'], max_value=max_dict['sqft_above'], value=1000)
35
- sqft_basement = st.slider('Square Feet (Basement)', min_value=min_dict['sqft_basement'], max_value=max_dict['sqft_basement'], value=0)
36
- yr_built = st.slider('Year Built', min_value=min_dict['yr_built'], max_value=max_dict['yr_built'], value=2000)
37
- yr_renovated = st.slider('Year Renovated', min_value=min_dict['yr_renovated'], max_value=max_dict['yr_renovated'], value=2010)
 
38
 
39
  st.markdown('</div>', unsafe_allow_html=True)
40
 
@@ -62,13 +63,13 @@ with col1:
62
  # Predict the price
63
  predicted_price = model.predict(new_pred)
64
 
65
- # Display the map in the second column
66
  with col2:
67
- # Placeholder for displaying the predicted price at the top
68
- price_placeholder = st.empty()
69
- price_placeholder.markdown(
70
- f"<h1 style='font-size: 24px;'>Predicted Price: ${predicted_price[0][0]:,.2f}</h1>",
71
- unsafe_allow_html=True)
72
-
73
- map_data = pd.DataFrame(cities_geo[city])
74
- st.map(map_data, zoom=11)
 
 
6
 
7
  st.set_page_config(layout="wide")
8
 
9
+ # Load model and files
10
  with open('./trained_model.pkl', 'rb') as file:
11
  model = pickle.load(file)
12
  with open("./min_dict.json", "r") as f:
 
22
  with col1:
23
  st.subheader('Features')
24
 
25
+ with st.container():
26
+ city = st.selectbox('City', list(cities_geo.keys())) # Display city dropdown in the first column
27
+ waterfront = st.checkbox('Waterfront', value=False)
28
+ bedrooms = st.slider('Bedrooms', min_value=min_dict['bedrooms'], max_value=max_dict['bedrooms'], value=3)
29
+ bathrooms = st.slider('Bathrooms', min_value=min_dict['bathrooms'], max_value=max_dict['bathrooms'], value=2)
30
+ sqft_living = st.slider('Square Feet (Living)', min_value=min_dict['sqft_living'], max_value=max_dict['sqft_living'], value=1000)
31
+ sqft_lot = st.slider('Square Feet (Lot)', min_value=min_dict['sqft_lot'], max_value=max_dict['sqft_lot'], value=2000)
32
+ floors = st.slider('Floors', min_value=min_dict['floors'], max_value=max_dict['floors'], value=1)
33
+ view = st.slider('View', min_value=min_dict['view'], max_value=max_dict['view'], value=0)
34
+ condition = st.slider('Condition', min_value=min_dict['condition'], max_value=min_dict['condition'], value=3)
35
+ sqft_above = st.slider('Square Feet (Above)', min_value=min_dict['sqft_above'], max_value=max_dict['sqft_above'], value=1000)
36
+ sqft_basement = st.slider('Square Feet (Basement)', min_value=min_dict['sqft_basement'], max_value=max_dict['sqft_basement'], value=0)
37
+ yr_built = st.slider('Year Built', min_value=min_dict['yr_built'], max_value=max_dict['yr_built'], value=2000)
38
+ yr_renovated = st.slider('Year Renovated', min_value=min_dict['yr_renovated'], max_value=min_dict['yr_renovated'], value=2010)
39
 
40
  st.markdown('</div>', unsafe_allow_html=True)
41
 
 
63
  # Predict the price
64
  predicted_price = model.predict(new_pred)
65
 
 
66
  with col2:
67
+ with st.container():
68
+ # Placeholder for displaying the predicted price at the top
69
+ price_placeholder = st.empty()
70
+ price_placeholder.markdown(
71
+ f"<h1 style='font-size: 24px;'>Predicted Price: ${predicted_price[0][0]:,.2f}</h1>",
72
+ unsafe_allow_html=True)
73
+
74
+ map_data = pd.DataFrame(cities_geo[city])
75
+ st.map(map_data, zoom=11)