Classification Metrics
Multiple metrics evaluate classification models beyond accuracy.
Accuracy, Precision, Recall
accuracy_score(y_true, y_pred). precision_score(y_true, y_pred). recall_score(y_true, y_pred).
Precision: of predicted positives, how many are correct. Recall: of actual positives, how many were predicted.
F1 Score and AUC
F1 combines precision and recall: f1_score(y_true, y_pred). The harmonic mean balances both.
AUC (ROC AUC): roc_auc_score(y_true, y_proba). Measures discrimination across thresholds.
Confusion Matrix
confusion_matrix(y_true, y_pred) shows prediction breakdown. Classification report provides comprehensive metrics.
Key Takeaways
- Accuracy is misleading for imbalanced data
- Precision, recall, F1 provide nuanced evaluation
- AUC evaluates ranking independent of threshold