Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,7 +1,3 @@
|
|
| 1 |
-
Share
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
You said:
|
| 5 |
import streamlit as st
|
| 6 |
import pandas as pd
|
| 7 |
from sklearn.model_selection import train_test_split
|
|
@@ -148,17 +144,21 @@ if uploaded_file is not None:
|
|
| 148 |
st.subheader("Classification Model Performance Metrics")
|
| 149 |
st.dataframe(metrics_df)
|
| 150 |
|
| 151 |
-
|
| 152 |
-
fig, ax = plt.subplots()
|
| 153 |
-
|
| 154 |
-
ax.
|
|
|
|
|
|
|
|
|
|
|
|
|
| 155 |
buf = BytesIO()
|
| 156 |
fig.savefig(buf, format="png")
|
| 157 |
buf.seek(0)
|
| 158 |
st.download_button(
|
| 159 |
-
label="Download Classification
|
| 160 |
data=buf,
|
| 161 |
-
file_name="
|
| 162 |
mime="image/png"
|
| 163 |
)
|
| 164 |
|
|
@@ -190,16 +190,22 @@ if uploaded_file is not None:
|
|
| 190 |
st.subheader("Regression Model Performance Metrics")
|
| 191 |
st.dataframe(regression_metrics_df)
|
| 192 |
|
| 193 |
-
# Save metrics as PNG
|
| 194 |
-
fig, ax = plt.subplots()
|
| 195 |
-
|
| 196 |
-
ax.
|
|
|
|
|
|
|
|
|
|
|
|
|
| 197 |
buf = BytesIO()
|
| 198 |
fig.savefig(buf, format="png")
|
| 199 |
buf.seek(0)
|
| 200 |
st.download_button(
|
| 201 |
-
label="Download Regression
|
| 202 |
data=buf,
|
| 203 |
-
file_name="
|
| 204 |
mime="image/png"
|
| 205 |
-
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
import pandas as pd
|
| 3 |
from sklearn.model_selection import train_test_split
|
|
|
|
| 144 |
st.subheader("Classification Model Performance Metrics")
|
| 145 |
st.dataframe(metrics_df)
|
| 146 |
|
| 147 |
+
# Save metrics as PNG (table form)
|
| 148 |
+
fig, ax = plt.subplots(figsize=(8, 4))
|
| 149 |
+
ax.axis('tight')
|
| 150 |
+
ax.axis('off')
|
| 151 |
+
table = plt.table(cellText=metrics_df.values, colLabels=metrics_df.columns, cellLoc='center', loc='center')
|
| 152 |
+
table.auto_set_font_size(False)
|
| 153 |
+
table.set_fontsize(10)
|
| 154 |
+
table.auto_set_column_width(col=list(range(len(metrics_df.columns))))
|
| 155 |
buf = BytesIO()
|
| 156 |
fig.savefig(buf, format="png")
|
| 157 |
buf.seek(0)
|
| 158 |
st.download_button(
|
| 159 |
+
label="Download Classification Metrics Table as PNG",
|
| 160 |
data=buf,
|
| 161 |
+
file_name="classification_metrics_table.png",
|
| 162 |
mime="image/png"
|
| 163 |
)
|
| 164 |
|
|
|
|
| 190 |
st.subheader("Regression Model Performance Metrics")
|
| 191 |
st.dataframe(regression_metrics_df)
|
| 192 |
|
| 193 |
+
# Save metrics as PNG (table form)
|
| 194 |
+
fig, ax = plt.subplots(figsize=(8, 4))
|
| 195 |
+
ax.axis('tight')
|
| 196 |
+
ax.axis('off')
|
| 197 |
+
table = plt.table(cellText=regression_metrics_df.values, colLabels=regression_metrics_df.columns, cellLoc='center', loc='center')
|
| 198 |
+
table.auto_set_font_size(False)
|
| 199 |
+
table.set_fontsize(10)
|
| 200 |
+
table.auto_set_column_width(col=list(range(len(regression_metrics_df.columns))))
|
| 201 |
buf = BytesIO()
|
| 202 |
fig.savefig(buf, format="png")
|
| 203 |
buf.seek(0)
|
| 204 |
st.download_button(
|
| 205 |
+
label="Download Regression Metrics Table as PNG",
|
| 206 |
data=buf,
|
| 207 |
+
file_name="regression_metrics_table.png",
|
| 208 |
mime="image/png"
|
| 209 |
+
)
|
| 210 |
+
|
| 211 |
+
|