ROC Curves & AUC
ROC Curves & AUC — Visualize the full threshold tradeoff in one curve.
The ROC curve traces how true-positive and false-positive rates trade off across every possible threshold. The area under it (AUC) summarizes the classifier’s ranking quality in a single number.
- ROC swept so far
- PR swept so far
- Not yet reached
- Operating point
- Cost-optimal
ROC controls
The idea in plain words
The ROC curve traces how the true-positive and false-positive rates trade off across everythreshold. The area under it (AUC) summarizes ranking quality in a single number: 1.0 is perfect, 0.5 is a coin flip.
Pull the two score distributions apart and the ROC morphs from the useless diagonal to the perfect corner. It complements precision–recall, though on heavily imbalanced data a high AUC can still hide poor precision.
Now, the math
The ROC plots the true-positive rate against the false-positive rate:
- recall — the vertical axis of the ROC.
- false-alarm rate — the horizontal axis.
- area under the curve — probability a random positive outranks a random negative.
▸ Show the derivation
Sweeping the threshold from high to low traces the curve from the origin to (1,1). AUC equals the probability that a randomly chosen positive scores higher than a randomly chosen negative, so it measures the model’s ranking independent of any single threshold.
Trace it by hand
Six scored points: positives at 0.9, 0.7, 0.4 and negatives at 0.6, 0.3, 0.1, with score at or above t predicting positive. We read TPR and FPR at two thresholds, then get AUC two independent ways. Rates verified with the site's threshold engine; rounded to 2 decimals.
A strict threshold, t = 0.65
Only 0.9 and 0.7 clear the bar — both positives, no false alarms. This is the ROC point (0, 0.67).
A lenient threshold, t = 0.35
Now every positive is caught, but the negative at 0.6 comes along as a false alarm: ROC point (0.33, 1).
Area under the full step curve
Sweeping every threshold traces a staircase of height two thirds over the first third of the FPR axis and height 1 over the rest.
Same number by counting pairs
Of the 3 times 3 positive-negative pairs, only one is misranked: the positive at 0.4 scores below the negative at 0.6.
What just happened: The two operating points (0, 0.67) and (0.33, 1) are just samples of one curve, and its area 8/9 has a concrete meaning: 8 of the 9 positive-negative pairs are ranked correctly. AUC grades the ranking itself, before any threshold is chosen.
Now Break It
Try this: On imbalanced data AUC looks great while precision at the useful threshold is terrible.
Control: Class balance slider (set imbalanced)
What happens: AUC can mislead! On imbalanced data a high AUC hides poor precision where it matters.
Where roc curves & auc is used
An ROC curve visualizes a classifier's performance across every possible decision threshold at once, rather than at a single cutoff. It plots the true positive rate against the false positive rate as the threshold sweeps from strict to lenient, tracing the full tradeoff between catching positives and raising false alarms. The area under the curve, or AUC, condenses this into one number with an intuitive meaning: it is the probability that the model ranks a randomly chosen positive higher than a randomly chosen negative. An AUC of 0.5 is no better than random guessing and 1.0 is perfect ranking. Because it is threshold-independent, AUC is popular for comparing models in medical diagnostics and credit scoring, where the final operating threshold is chosen later.
A major pitfall is relying on ROC AUC for highly imbalanced data, where it can look reassuringly high even when the model performs poorly on the rare class. The false positive rate has a large negative denominator, so many false positives barely move the curve; a precision-recall curve is more informative in that setting because it focuses on the positive class. Another misconception is reading AUC as accuracy or as a probability of being correct; it is a ranking measure and says nothing about calibration or the quality of predictions at any particular threshold. A model can have excellent AUC yet still need a carefully chosen threshold to be useful in practice.
Frequently asked questions
What does AUC actually measure?
What is the difference between an ROC curve and a precision-recall curve?
Is a higher AUC always better?
Why is an AUC of 0.5 considered random?
Can AUC be misleading?
Written & reviewed by the ML Visualization team · Last updated .