Spaces:
Sleeping
Sleeping
| 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 |