add r2 score
continuous-integration/drone/push Build is passing Details

pull/14/head
Bastien OLLIER 10 months ago
parent 27e69b2af8
commit da1e97f07f

@ -67,7 +67,6 @@ if "data" in st.session_state:
fig = plt.figure() fig = plt.figure()
y_pred = [model.predict(pd.DataFrame([pred_value[0]], columns=data_name)) for pred_value in X.values.tolist()] y_pred = [model.predict(pd.DataFrame([pred_value[0]], columns=data_name)) for pred_value in X.values.tolist()]
print([x[0] for x in X.values.tolist()])
cm = confusion_matrix(y, y_pred) cm = confusion_matrix(y, y_pred)
sns.heatmap(cm, annot=True, fmt="d") sns.heatmap(cm, annot=True, fmt="d")
@ -75,9 +74,6 @@ if "data" in st.session_state:
plt.xlabel('Predicted') plt.xlabel('Predicted')
plt.ylabel('True') plt.ylabel('True')
st.pyplot(fig) st.pyplot(fig, figsize=(1, 1))
else: else:
st.error("File not loaded") st.error("File not loaded")

@ -1,5 +1,6 @@
import streamlit as st import streamlit as st
from sklearn.linear_model import LinearRegression from sklearn.linear_model import LinearRegression
from sklearn.metrics import r2_score
import pandas as pd import pandas as pd
import matplotlib.pyplot as plt import matplotlib.pyplot as plt
@ -21,6 +22,10 @@ if "data" in st.session_state:
model = LinearRegression() model = LinearRegression()
model.fit(X, y) model.fit(X, y)
y_pred = [model.predict(pd.DataFrame([pred_value[0]], columns=data_name)) for pred_value in X.values.tolist()]
r2 = r2_score(y, y_pred)
st.write('R-squared score:', r2)
st.subheader("Enter values for prediction") st.subheader("Enter values for prediction")
pred_values = [st.number_input(f"Value for {feature}", value=0.0) for feature in data_name] pred_values = [st.number_input(f"Value for {feature}", value=0.0) for feature in data_name]
prediction = model.predict(pd.DataFrame([pred_values], columns=data_name)) prediction = model.predict(pd.DataFrame([pred_values], columns=data_name))

Loading…
Cancel
Save