YoneSlapWind80085 commited on
Commit
486f5eb
·
verified ·
1 Parent(s): 0acf091

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -18
app.py CHANGED
@@ -190,25 +190,16 @@ if st.checkbox('Show raw data'):
190
 
191
  # Visualization of selected feature
192
  st.subheader(f'Distribution of {selected_feature}')
193
- plt.figure(figsize=(10, 6))
194
- plt.hist(df[selected_feature], bins=30, edgecolor='black')
195
- st.pyplot(plt)
196
 
197
  # Scatter plot of selected feature vs target
198
  st.subheader(f'Scatter plot of {selected_feature} vs {selected_target}')
199
- plt.figure(figsize=(10, 6))
200
- plt.scatter(df[selected_feature], df[selected_target], alpha=0.3)
201
- plt.xlabel(selected_feature)
202
- plt.ylabel(selected_target)
203
- st.pyplot(plt)
204
-
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')
@@ -219,7 +210,7 @@ if show_regression and selected_feature in X.columns and selected_target == 'Med
219
  line = model_feature.predict(X_feature)
220
  ax.plot(df[selected_feature], line, color='red', linewidth=2)
221
 
222
- st.pyplot(residuals)
223
 
224
  # Prediction
225
  st.subheader('Predict Median House Value')
@@ -234,4 +225,3 @@ if st.button('Predict'):
234
  prediction = model.predict(input_data)
235
  st.write(f'Predicted Median House Value: {prediction[0]}')
236
 
237
-
 
190
 
191
  # Visualization of selected feature
192
  st.subheader(f'Distribution of {selected_feature}')
193
+ fig, ax = plt.subplots()
194
+ ax.hist(df[selected_feature], bins=30, edgecolor='black')
195
+ st.pyplot(fig)
196
 
197
  # Scatter plot of selected feature vs target
198
  st.subheader(f'Scatter plot of {selected_feature} vs {selected_target}')
199
+ fig, ax = plt.subplots()
200
+ ax.scatter(df[selected_feature], df[selected_target], alpha=0.3)
201
+ ax.set_xlabel(selected_feature)
202
+ ax.set_ylabel(selected_target)
 
 
 
 
 
 
 
 
 
203
 
204
  # Show regression line if selected
205
  show_regression = st.checkbox('Show Regression Line')
 
210
  line = model_feature.predict(X_feature)
211
  ax.plot(df[selected_feature], line, color='red', linewidth=2)
212
 
213
+ st.pyplot(fig)
214
 
215
  # Prediction
216
  st.subheader('Predict Median House Value')
 
225
  prediction = model.predict(input_data)
226
  st.write(f'Predicted Median House Value: {prediction[0]}')
227