SDE & MLE Prep

Evaluation Metrics

Q: Precision vs recall, ROC-AUC vs PR-AUC — when to use which?

                  predicted +    predicted -
actual +             TP              FN
actual -             FP              TN

precision = TP / (TP + FP)      "of what I flagged, how much was right"
recall    = TP / (TP + FN)      "of all positives, how many did I catch"   (= TPR, sensitivity)
FPR       = FP / (FP + TN)
F1        = 2PR / (P + R)
  • Precision matters when false positives are costly (spam filter hiding real mail); recall when misses are costly (cancer screening, fraud).
  • ROC-AUC: TPR vs FPR over thresholds; = probability a random positive scores above a random negative. Insensitive to class balance — can look great on very imbalanced data.
  • PR-AUC / average precision: better for rare positives.
  • Log loss & calibration (reliability diagrams, Platt/isotonic scaling) when probabilities are used downstream (ads bidding).
  • Ranking: NDCG@k, MAP, MRR, recall@k.
  • Regression: MAE (robust to outliers), RMSE (penalizes large errors), R², MAPE.
  • Always tie the offline metric to the business metric and verify with A/B tests.