Accuracy alone is misleading — especially with imbalanced classes. Precision, recall and F1 tell you what kind of errors your classifier makes.
The key metrics
| Metric | Answers |
|---|---|
Accuracy | Fraction correct — misleading if classes are imbalanced |
Precision | Of predicted positives, how many are right? |
Recall | Of actual positives, how many did we catch? |
F1 | Harmonic mean of precision and recall |
from sklearn.metrics import classification_reportprint(classification_report(y_test, model.predict(X_test)))# precision, recall, f1 per class + accuracy
Why accuracy misleads
Key takeaways
- 01Accuracy is misleading with imbalanced classes.
- 02Precision = correct among predicted positives; recall = caught among actual positives.
- 03F1 is the harmonic mean of precision and recall.
- 04classification_report gives all of them per class; choose the metric that fits the cost of each error.
