Spaces:
Paused
Paused
Update app.py
Browse files
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 |
-
#
|
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 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
|
|
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 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
|
|
|
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)
|