Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -114,9 +114,13 @@ if uploaded_file is not None:
|
|
| 114 |
for name, model in model_choices:
|
| 115 |
model.fit(X_train, y_train)
|
| 116 |
y_pred = model.predict(X_test)
|
|
|
|
|
|
|
| 117 |
accuracy = accuracy_score(y_test, y_pred)
|
| 118 |
-
|
| 119 |
-
|
|
|
|
|
|
|
| 120 |
|
| 121 |
else: # Regression models
|
| 122 |
model_choices = [
|
|
@@ -131,12 +135,17 @@ if uploaded_file is not None:
|
|
| 131 |
for name, model in model_choices:
|
| 132 |
model.fit(X_train, y_train)
|
| 133 |
y_pred = model.predict(X_test)
|
|
|
|
|
|
|
| 134 |
mse = mean_squared_error(y_test, y_pred)
|
|
|
|
|
|
|
| 135 |
results.append([name, None, mse])
|
| 136 |
|
| 137 |
# Display results in a table
|
| 138 |
st.subheader("Model Performance Results")
|
| 139 |
-
results_df = pd.DataFrame(results, columns=["Model", "Accuracy" if is_classification else "Accuracy (N/A)",
|
|
|
|
| 140 |
|
| 141 |
# Bold the headers
|
| 142 |
st.markdown(f"**Model Performance Results**")
|
|
|
|
| 114 |
for name, model in model_choices:
|
| 115 |
model.fit(X_train, y_train)
|
| 116 |
y_pred = model.predict(X_test)
|
| 117 |
+
|
| 118 |
+
# Accuracy and Classification Report
|
| 119 |
accuracy = accuracy_score(y_test, y_pred)
|
| 120 |
+
classification_report_output = classification_report(y_test, y_pred)
|
| 121 |
+
|
| 122 |
+
# Append results
|
| 123 |
+
results.append([name, accuracy, classification_report_output])
|
| 124 |
|
| 125 |
else: # Regression models
|
| 126 |
model_choices = [
|
|
|
|
| 135 |
for name, model in model_choices:
|
| 136 |
model.fit(X_train, y_train)
|
| 137 |
y_pred = model.predict(X_test)
|
| 138 |
+
|
| 139 |
+
# Mean Squared Error (MSE) for regression tasks
|
| 140 |
mse = mean_squared_error(y_test, y_pred)
|
| 141 |
+
|
| 142 |
+
# Append results
|
| 143 |
results.append([name, None, mse])
|
| 144 |
|
| 145 |
# Display results in a table
|
| 146 |
st.subheader("Model Performance Results")
|
| 147 |
+
results_df = pd.DataFrame(results, columns=["Model", "Accuracy" if is_classification else "Accuracy (N/A)",
|
| 148 |
+
"Classification Report" if is_classification else "MSE (N/A)"])
|
| 149 |
|
| 150 |
# Bold the headers
|
| 151 |
st.markdown(f"**Model Performance Results**")
|