Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -305,13 +305,13 @@ def evaluate_model(model, X_test, y_test, model_name):
|
|
305 |
Evaluates the performance of a trained model on test data using various metrics.
|
306 |
"""
|
307 |
# Make predictions
|
308 |
-
y_pred = model.predict(X_test)
|
309 |
|
310 |
# Get classification report
|
311 |
-
report = classification_report(y_test, y_pred, output_dict=True)
|
312 |
|
313 |
# Extracting metrics
|
314 |
-
metrics = {
|
315 |
"precision_0": report["0"]["precision"],
|
316 |
"precision_1": report["1"]["precision"],
|
317 |
"recall_0": report["0"]["recall"],
|
@@ -322,7 +322,7 @@ metrics = {
|
|
322 |
"macro_avg_recall": report["macro avg"]["recall"],
|
323 |
"macro_avg_f1": report["macro avg"]["f1-score"],
|
324 |
"accuracy": accuracy_score(y_test, y_pred)
|
325 |
-
}
|
326 |
|
327 |
# Convert dictionary to dataframe
|
328 |
df = pd.DataFrame(metrics, index=[model_name]).round(2)
|
|
|
305 |
Evaluates the performance of a trained model on test data using various metrics.
|
306 |
"""
|
307 |
# Make predictions
|
308 |
+
y_pred = model.predict(X_test)
|
309 |
|
310 |
# Get classification report
|
311 |
+
report = classification_report(y_test, y_pred, output_dict=True)
|
312 |
|
313 |
# Extracting metrics
|
314 |
+
metrics = {
|
315 |
"precision_0": report["0"]["precision"],
|
316 |
"precision_1": report["1"]["precision"],
|
317 |
"recall_0": report["0"]["recall"],
|
|
|
322 |
"macro_avg_recall": report["macro avg"]["recall"],
|
323 |
"macro_avg_f1": report["macro avg"]["f1-score"],
|
324 |
"accuracy": accuracy_score(y_test, y_pred)
|
325 |
+
}
|
326 |
|
327 |
# Convert dictionary to dataframe
|
328 |
df = pd.DataFrame(metrics, index=[model_name]).round(2)
|