YoneSlapWind80085 commited on
Commit
e7e45cc
·
verified ·
1 Parent(s): a3e474b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -3
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
- # Display data
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
+