Spaces:
Sleeping
Sleeping
Update app.py
Browse files
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.
|
194 |
-
|
195 |
-
st.pyplot(
|
196 |
|
197 |
# Scatter plot of selected feature vs target
|
198 |
st.subheader(f'Scatter plot of {selected_feature} vs {selected_target}')
|
199 |
-
plt.
|
200 |
-
|
201 |
-
|
202 |
-
|
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(
|
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 |
|
|