ml

🟠 ML: Classification Metrics — When to Use What

Confusion matrix:

Predicted + Predicted -
Actually + TP FN
Actually - FP TN

Precision = TP/(TP+FP) — "Of everything I flagged, how many were correct?" → Use when false positives are costly (spam filter — don't block real emails)

Recall = TP/(TP+FN) — "Of everything actually positive, how many did I catch?" → Use when false negatives are costly (cancer screening — don't miss cancer)

F1 = 2 Ɨ (PƗR)/(P+R) — harmonic mean, balances both.

Accuracy = (TP+TN)/Total — NEVER use for imbalanced data (predicting majority class always = high accuracy but useless)

ROC-AUC: Good for comparing models. Can be misleadingly optimistic on imbalanced data. PR-AUC: Better than ROC-AUC for imbalanced data — focuses on the positive class.

Practice Questions

Q: You're building a fraud detection system. What metric do you prioritize and why?