Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -2,6 +2,7 @@ import streamlit as st
|
|
| 2 |
import numpy as np
|
| 3 |
from sklearn.linear_model import LinearRegression
|
| 4 |
import matplotlib.pyplot as plt
|
|
|
|
| 5 |
|
| 6 |
# Function for linear regression
|
| 7 |
def perform_linear_regression(X, Y):
|
|
@@ -70,7 +71,14 @@ if len(x_values) == 3 and len(y_values) == 3:
|
|
| 70 |
|
| 71 |
if test_x_input:
|
| 72 |
predicted_y = model.predict(np.array([[test_x_input]]))[0]
|
| 73 |
-
|
| 74 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 75 |
else:
|
| 76 |
st.write("Please provide valid inputs with 3 values each.")
|
|
|
|
| 2 |
import numpy as np
|
| 3 |
from sklearn.linear_model import LinearRegression
|
| 4 |
import matplotlib.pyplot as plt
|
| 5 |
+
from sklearn.metrics import mean_squared_error, r2_score
|
| 6 |
|
| 7 |
# Function for linear regression
|
| 8 |
def perform_linear_regression(X, Y):
|
|
|
|
| 71 |
|
| 72 |
if test_x_input:
|
| 73 |
predicted_y = model.predict(np.array([[test_x_input]]))[0]
|
| 74 |
+
st.write(f"Predicted Y for X = {test_x_input}: {predicted_y}")
|
| 75 |
+
|
| 76 |
+
# Performance metrics
|
| 77 |
+
y_predicted = model.predict(X)
|
| 78 |
+
mse = mean_squared_error(Y, y_predicted)
|
| 79 |
+
#r2 = r2_score(Y, y_predicted)
|
| 80 |
+
|
| 81 |
+
st.write(f"Mean Squared Error: {mse}")
|
| 82 |
+
#st.write(f"R^2 Score: {r2}")
|
| 83 |
else:
|
| 84 |
st.write("Please provide valid inputs with 3 values each.")
|