Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -205,6 +205,25 @@ st.pyplot(plt)
|
|
205 |
# Prediction
|
206 |
st.subheader('Predict Median House Value')
|
207 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
208 |
# Input values for prediction
|
209 |
input_values = {}
|
210 |
for feature in X.columns:
|
@@ -215,6 +234,4 @@ if st.button('Predict'):
|
|
215 |
prediction = model.predict(input_data)
|
216 |
st.write(f'Predicted Median House Value: {prediction[0]}')
|
217 |
|
218 |
-
|
219 |
-
if st.checkbox('Show raw data'):
|
220 |
-
st.write(df)
|
|
|
205 |
# Prediction
|
206 |
st.subheader('Predict Median House Value')
|
207 |
|
208 |
+
# Input values for prediction
|
209 |
+
input_values = {}
|
210 |
+
for feature in X.columns:
|
211 |
+
input_values[feature] = st.number_input(f'Enter {feature}', value=float(df[feature].mean()))
|
212 |
+
|
213 |
+
# Show regression line if selected
|
214 |
+
show_regression = st.checkbox('Show Regression Line')
|
215 |
+
if show_regression and selected_feature in X.columns and selected_target == 'MedHouseVal':
|
216 |
+
X_feature = df[[selected_feature]]
|
217 |
+
model_feature = LinearRegression()
|
218 |
+
model_feature.fit(X_feature, y)
|
219 |
+
line = model_feature.predict(X_feature)
|
220 |
+
ax.plot(df[selected_feature], line, color='red', linewidth=2)
|
221 |
+
|
222 |
+
st.pyplot(fig)
|
223 |
+
|
224 |
+
# Prediction
|
225 |
+
st.subheader('Predict Median House Value')
|
226 |
+
|
227 |
# Input values for prediction
|
228 |
input_values = {}
|
229 |
for feature in X.columns:
|
|
|
234 |
prediction = model.predict(input_data)
|
235 |
st.write(f'Predicted Median House Value: {prediction[0]}')
|
236 |
|
237 |
+
|
|
|
|