Spaces:
Sleeping
Sleeping
File size: 690 Bytes
510a9b0 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
import pandas as pd
from sklearn.metrics import classification_report
def evaluate_predictions(y_true, y_pred):
"""
Evaluates predictions by converting labels to strings and generating a classification report.
Args:
y_true (pd.Series or list): True labels.
y_pred (pd.Series or list): Predicted labels.
Returns:
dict: Classification report as a dictionary.
"""
# Ensure both true and predicted labels are strings
y_true_str = pd.Series(y_true).astype(str)
y_pred_str = pd.Series(y_pred).astype(str)
# Generate classification report
report = classification_report(y_true_str, y_pred_str, output_dict=True)
return report |