Spaces:
Sleeping
Sleeping
Update pages/4_Model Creation and Evaluation.py
Browse files
pages/4_Model Creation and Evaluation.py
CHANGED
|
@@ -264,6 +264,14 @@ conf_matrix_svc
|
|
| 264 |
"""
|
| 265 |
st.code(code_5, language='python')
|
| 266 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 267 |
# Calculate accuracy for SVC
|
| 268 |
svc_accuracy = accuracy_score(y_test, y_pred_svc)
|
| 269 |
|
|
@@ -272,7 +280,7 @@ st.write(f"Accuracy for SVC: {svc_accuracy:.2f}")
|
|
| 272 |
|
| 273 |
# Display classification report
|
| 274 |
st.write("Classification Report for SVC:")
|
| 275 |
-
st.text(classification_report(y_test, y_pred_svc)) # Use st.text for
|
| 276 |
|
| 277 |
# Compute confusion matrix
|
| 278 |
conf_matrix_svc = confusion_matrix(y_test, y_pred_svc)
|
|
@@ -280,21 +288,20 @@ st.write("Confusion Matrix for SVC:")
|
|
| 280 |
st.write(conf_matrix_svc)
|
| 281 |
|
| 282 |
# Plot the confusion matrix using matplotlib and seaborn
|
| 283 |
-
plt.figure(figsize=(8, 6)) # Adjust figure size
|
| 284 |
sns.heatmap(conf_matrix_svc, annot=True, fmt="d", cmap="Blues", cbar=False, annot_kws={"size": 10})
|
| 285 |
|
| 286 |
-
#
|
| 287 |
plt.title("Confusion Matrix for SVC", fontsize=14)
|
| 288 |
plt.xlabel("Predicted Labels", fontsize=12)
|
| 289 |
plt.ylabel("True Labels", fontsize=12)
|
| 290 |
|
| 291 |
-
# Rotate tick labels for
|
| 292 |
plt.xticks(rotation=45, ha='right')
|
| 293 |
plt.yticks(rotation=45, va='center')
|
| 294 |
|
| 295 |
# Display the plot in Streamlit
|
| 296 |
st.pyplot(plt)
|
| 297 |
-
import streamlit as st
|
| 298 |
|
| 299 |
# Custom CSS for buttons
|
| 300 |
st.markdown(
|
|
|
|
| 264 |
"""
|
| 265 |
st.code(code_5, language='python')
|
| 266 |
|
| 267 |
+
# Import necessary libraries
|
| 268 |
+
import matplotlib.pyplot as plt # Import for plotting
|
| 269 |
+
import seaborn as sns # Import for advanced visualizations
|
| 270 |
+
from sklearn.metrics import accuracy_score, classification_report, confusion_matrix # Metrics for evaluation
|
| 271 |
+
|
| 272 |
+
# Step 5: Model Evaluation
|
| 273 |
+
st.subheader("Step 5: Model Evaluation")
|
| 274 |
+
|
| 275 |
# Calculate accuracy for SVC
|
| 276 |
svc_accuracy = accuracy_score(y_test, y_pred_svc)
|
| 277 |
|
|
|
|
| 280 |
|
| 281 |
# Display classification report
|
| 282 |
st.write("Classification Report for SVC:")
|
| 283 |
+
st.text(classification_report(y_test, y_pred_svc)) # Use st.text for better text formatting in Streamlit
|
| 284 |
|
| 285 |
# Compute confusion matrix
|
| 286 |
conf_matrix_svc = confusion_matrix(y_test, y_pred_svc)
|
|
|
|
| 288 |
st.write(conf_matrix_svc)
|
| 289 |
|
| 290 |
# Plot the confusion matrix using matplotlib and seaborn
|
| 291 |
+
plt.figure(figsize=(8, 6)) # Adjust figure size for better display
|
| 292 |
sns.heatmap(conf_matrix_svc, annot=True, fmt="d", cmap="Blues", cbar=False, annot_kws={"size": 10})
|
| 293 |
|
| 294 |
+
# Add titles and axis labels
|
| 295 |
plt.title("Confusion Matrix for SVC", fontsize=14)
|
| 296 |
plt.xlabel("Predicted Labels", fontsize=12)
|
| 297 |
plt.ylabel("True Labels", fontsize=12)
|
| 298 |
|
| 299 |
+
# Rotate tick labels for readability
|
| 300 |
plt.xticks(rotation=45, ha='right')
|
| 301 |
plt.yticks(rotation=45, va='center')
|
| 302 |
|
| 303 |
# Display the plot in Streamlit
|
| 304 |
st.pyplot(plt)
|
|
|
|
| 305 |
|
| 306 |
# Custom CSS for buttons
|
| 307 |
st.markdown(
|