Interactive statistics

56 free interactive lessons: from mean and median to A/B tests and Bayes. Drag the charts and build intuition. No sign-up.

Module 8: Classification

The ROC curve and AUC

In the previous lesson we moved the threshold and saw precision and recall trade off. But there are infinitely many thresholds, and tying yourself to one is unappealing. The ROC curve shows the classifier's behavior at all thresholds at once, and AUC rolls its quality into a single number. Move the threshold and the class separability β€” the curve and the point respond live.

FPR (false alarms) β†’TPR (spam caught) β†’AUC 1.00
AUC: 1.00current threshold: TPR 100% / FPR 0%

The threshold moves the yellow dot along the curve. Better separability β€” the curve hugs the top left corner, and the area under it (AUC) grows. AUC = 0.5 (the diagonal) β€” the model is no better than a coin.

The curve is built like this: sweep all thresholds from the strictest to the most lenient, and for each compute two shares from the confusion matrix β€” FPR (the false positive rate, horizontal) and TPR (the share of spam caught, vertical). Each threshold gives one point; connected, they form the ROC curve. The yellow dot is the current threshold; drag the slider and watch it ride along the curve.

What it means

AUC is the standard metric for comparing classifiers: models in credit scoring, medicine and anti-fraud are chosen by it. Conveniently, AUC depends neither on the threshold nor on how rare the class is β€” so it is more honest than the "share of correct answers", which deceives under imbalance.

But AUC is about ranking overall, not about a specific decision. Having chosen a model by AUC, you still set the operating point (the threshold) separately: by what costs more β€” a miss or a false alarm. On heavily imbalanced tasks you additionally look at the PR curve (precision against recall).

Where it shows up

From radar, ROC migrated to medicine (how well a test separates the sick from the healthy) and from there to all of machine learning: disease detectors, anti-fraud, recommender systems, credit models.

When a paper or a dashboard says "AUC 0.87", read it as: take a random "positive" and a random "negative" β€” in 87% of cases the model scores the first one higher. A handy common language for classifier quality.

Definitions
ROC curve
the plot of TPR against FPR across all thresholds. Shows all of the classifier's trade-offs at once.
TPR and FPR
TPR β€” the share of the target class caught (recall); FPR β€” the share of false alarms among the "clean" ones.
AUCarea under the ROC
1.0 β€” ideal, 0.5 β€” chance. Equals the probability that a positive gets a higher score than a negative.
Receiver Operating Characteristic
the historical name from radar: the characteristic of a receiver telling signal from noise.
Next β†’
Enjoying the materials?

This site is built by the DataSlice Telegram channel: data analytics in plain words β€” real cases, metrics, careers. The channel is in Russian.

Open the Telegram channel