Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,7 +1,9 @@
|
|
1 |
import streamlit as st
|
2 |
import pandas as pd
|
|
|
3 |
from sklearn.model_selection import train_test_split
|
4 |
from sklearn.linear_model import LinearRegression
|
|
|
5 |
|
6 |
# Load the dataset
|
7 |
@st.cache_data
|
@@ -35,13 +37,21 @@ if selected_features:
|
|
35 |
# Prediction
|
36 |
y_pred = model.predict(X_test)
|
37 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
38 |
# Display results
|
39 |
st.write("Selected Features", selected_features)
|
40 |
st.write("Model Coefficients", model.coef_)
|
41 |
st.write("Predictions", y_pred)
|
42 |
st.write("Actual Values", y_test.values)
|
43 |
-
|
44 |
-
# Model performance
|
45 |
-
from sklearn.metrics import mean_squared_error, r2_score
|
46 |
-
st.write("Mean Squared Error", mean_squared_error(y_test, y_pred))
|
47 |
-
st.write("R-squared Score", r2_score(y_test, y_pred))
|
|
|
1 |
import streamlit as st
|
2 |
import pandas as pd
|
3 |
+
import matplotlib.pyplot as plt
|
4 |
from sklearn.model_selection import train_test_split
|
5 |
from sklearn.linear_model import LinearRegression
|
6 |
+
from sklearn.metrics import mean_squared_error, r2_score
|
7 |
|
8 |
# Load the dataset
|
9 |
@st.cache_data
|
|
|
37 |
# Prediction
|
38 |
y_pred = model.predict(X_test)
|
39 |
|
40 |
+
|
41 |
+
# Plot
|
42 |
+
fig, ax = plt.subplots()
|
43 |
+
ax.scatter(y_test, y_pred, edgecolors=(0, 0, 0))
|
44 |
+
ax.plot([y_test.min(), y_test.max()], [y_test.min(), y_test.max()], 'k--', lw=4)
|
45 |
+
ax.set_xlabel('Actual')
|
46 |
+
ax.set_ylabel('Predicted')
|
47 |
+
ax.set_title('Actual vs Predicted')
|
48 |
+
st.pyplot(fig)
|
49 |
+
|
50 |
+
# Model performance
|
51 |
+
st.write("Mean Squared Error", mean_squared_error(y_test, y_pred))
|
52 |
+
st.write("R-squared Score", r2_score(y_test, y_pred))
|
53 |
# Display results
|
54 |
st.write("Selected Features", selected_features)
|
55 |
st.write("Model Coefficients", model.coef_)
|
56 |
st.write("Predictions", y_pred)
|
57 |
st.write("Actual Values", y_test.values)
|
|
|
|
|
|
|
|
|
|