ROC and AUC

Context: FIT2086_MOC · the metric that scores a classifier at every threshold at once, instead of freezing it at · one layer above the single confusion matrix of Classification Evaluation (Confusion Matrix and Metrics) · applied to the probabilities produced by Logistic Regression · the ranking counterpart to the calibration measure Logarithmic Loss

Quick Revision

  • 🎯 Objective: sweep the detection threshold from to ➔ trace as a ROC curve ➔ the area under it is the AUC, a threshold-free score.
  • 📦 Core Components: small ➔ high sensitivity, more false positives | large ➔ high specificity, more false negatives | perfect · random · perfectly wrong.
  • ⚡ Key Constraint: AUC scores only the ranking of the predicted probabilities — a model can rank perfectly () while every probability it reports is badly calibrated.

📝 How It Works

1. The Detection Threshold

  • Definition ➔ choose and set whenever , otherwise .
  • The default is a choice ➔ classifying by “whichever class is more likely” is exactly ⟹ the argmax rule is one point on a whole family of rules.
  • Each is a different classifier ➔ it produces its own confusion matrix, and therefore its own and .

2. The Sensitivity–Specificity Trade-off

  • Small ➔ almost everyone is called positive ➔ sensitivity rises, and the price is more false positives (specificity falls).
  • Large ➔ only confident cases are called positive ➔ specificity rises, and the price is more false negatives (sensitivity falls).
  • No free lunch ➔ high sensitivity is always bought at the expense of specificity and vice versa ⟹ a single confusion matrix reports one arbitrary point on this trade-off.
  • Degenerate ends ➔ gives ; gives — the two corners every ROC curve joins.

3. The ROC Curve

  • Construction ➔ vary across , plot sensitivity against specificity ➔ the receiver operating characteristic.
  • Equivalent axes ➔ the lecture plots sensitivity against specificity with its axis reversed — the same curve, drawn right-to-left.
  • Reading the plot ➔ the ideal classifier hugs the top-left corner (all positives caught with no false alarms); the diagonal is random guessing.
  • What it fixes ➔ it removes the analyst’s arbitrary choice of from the comparison of two models.

4. AUC — the Area Under That Curve

  • Definition ➔ the area under the ROC curve; bigger area = better classifier.
  • Bounds and landmarks ➔ perfect classification is achievable · no better than a random guess · perfect misclassification (the model is right about everything, with the labels flipped).
  • Probabilistic interpretation ➔ assuming no tied scores, means that for a randomly drawn true positive and a randomly drawn true negative :
  • Plain reading ➔ AUC is the probability that the model scores a randomly chosen positive above a randomly chosen negative ⟹ it is a measure of ranking quality, indifferent to the absolute probability values.
  • Hand computation ➔ over all positive–negative pairs, count for each correctly ordered pair, for each tie, otherwise, then divide by the number of pairs.

⚖️ Core Decision Matrix

MeasureWhat it scoresThreshold needed?Blind to
Classification accuracylabels at one operating pointyes ()the trade-off at every other ; class imbalance
Sensitivity / specificitythe two error types separately at one yeshow the pair moves as changes
AUCthe ranking across all nocalibration — the actual probability values
Logarithmic Lossthe probability values themselvesnonothing about ranking, but heavily punishes confident errors

When It Flips: AUC is the right comparison when the operating threshold is not yet fixed or the classes are imbalanced. Once the deployment threshold is decided by real error costs, sensitivity and specificity at that are what matter — a higher-AUC model can still be the worse choice at your specific operating point.

📊 Exam Execution Trace & Applied Exercises

Applied Exercise — AUC by hand from a ranked score list

Problem: eight test individuals, sorted by predicted . Compute the AUC for each case.

Case values in score order (scores )
1 — the fourth score is
2 — the fourth score is

Final Extracted Output: Case 1 ; Case 2 . Equivalently, of the positive–negative pairs are correctly ordered, and — one badly ranked negative costs of AUC.

⚠️ Common Mistakes

  • 💡 Treating as “useless” ➔ useless is ; an AUC of is a perfectly informative model with its labels inverted, and flipping them gives .
  • 💡 Reading AUC as an accuracy ➔ it is a probability about pairs, not about individuals; a model can have and terrible accuracy at if the scores are shifted.
  • 💡 Quoting sensitivity without its threshold ➔ sensitivity and specificity are meaningless without the that produced them, because both are functions , .
  • 💡 Choosing by default in a costly-error setting ➔ optimises the count of mistakes, not their cost; move toward the error you can afford.

🧠 Active Recall