On this page
A model that flags spam or reads a scan rarely says a plain yes or no. It gives each case a score, and you choose a cut-off. The ROC curve shows every cut-off's trade-off on one graph, and the area under it squeezes them into one number.
What is an ROC curve?
An ROC curve plots the true positive rate (TPR) on the y-axis against the false positive rate (FPR) on the x-axis, computed at every possible threshold, as Google's Machine Learning Crash Course defines it. The long name, receiver operating characteristic, is a holdover from Second World War radar detection, the same page notes.
The two rates are simple fractions:
TPR = positives scored at or above the threshold ÷ all positives (also called sensitivity or recall)
FPR = negatives scored at or above the threshold ÷ all negatives
A perfect model reaches the top-left corner, TPR 1 with FPR 0. A model that guesses at random traces the diagonal from (0, 0) to (1, 1).
How do you draw an ROC curve by hand?
Take 8 examples, 4 positive (P) and 4 negative (N), and sort them by score, highest first. Now lower the threshold past one example at a time. Each positive you pass moves the curve up by 1/4; each negative moves it right by 1/4. The points are (FPR, TPR):
Threshold above every score: (0, 0)
Score 0.95, P: (0, 0.25)
Score 0.85, P: (0, 0.50)
Score 0.75, N: (0.25, 0.50)
Score 0.65, P: (0.25, 0.75)
Score 0.55, N: (0.50, 0.75)
Score 0.45, P: (0.50, 1.00)
Score 0.35, N: (0.75, 1.00)
Score 0.20, N: (1.00, 1.00)
Join the points and you get the staircase in the diagram at the top of this post. The area under it is three rectangles: 0.25 × 0.50 + 0.25 × 0.75 + 0.50 × 1.00 = 0.125 + 0.1875 + 0.5 = 0.8125.
If you have worked through logistic regression mathematics step by step or softmax and cross-entropy by hand, these scores are the probabilities such models output.
What does AUC actually mean?
The area under the ROC curve equals the probability that a randomly chosen positive is ranked above a randomly chosen negative, as Hanley and McNeil showed in Radiology in 1982. They also showed it is the same quantity estimated by the Wilcoxon statistic.
Check it on our table. There are 4 × 4 = 16 positive-negative pairs. Count the pairs the positive wins:
0.95 beats all four negatives: 4
0.85 beats all four: 4
0.65 beats 0.55, 0.35 and 0.20: 3
0.45 beats 0.35 and 0.20: 2
That is 13 wins out of 16, and 13/16 = 0.8125, exactly the area of the rectangles. An AUC of 0.5 means a positive outranks a negative only half the time, no better than a coin, per Google's crash course.
AUC does not tell you which threshold to use. It measures how well the scores rank cases, not how good any single cut-off is.
When does AUC mislead?
AUC can look excellent on imbalanced data, where negatives vastly outnumber positives. Saito and Rehmsmeier (PLOS ONE, 2015) showed that ROC plots on imbalanced datasets can be deceptive about how reliable a classifier is, because specificity invites an intuitive but wrong reading, and that precision-recall plots give a more accurate picture of future performance.
Here is why, with round numbers we chose. A screening model sees 10,000 negatives and 100 positives. At one threshold it catches 80 positives (TPR 0.8) and wrongly flags 500 negatives (FPR 0.05). On the ROC graph that point looks strong. But only 80 of the 580 alarms are real: precision is about 14%.
This is the base-rate trap behind the prosecutor's fallacy and conditional probability: a small error rate on a huge group still makes many errors. Google's crash course likewise suggests precision-recall curves when the classes are imbalanced.
A checklist before you trust an AUC
Check the class balance. If positives are rare, look at precision before you celebrate a high AUC.
Ask what the scores are for. Ranking suits AUC; a yes-or-no decision needs TPR, FPR and precision at your actual threshold.
Compare models on the same test set.
Look at the curve, not only the number. Two curves with equal area can cross.
Practise by hand: redo the table with two tied scores.
If true and false positive rates or conditional probability still feel slippery, the Fermi Concept Library has a lesson for every concept in mathematics and computing, each with its place in the map. To practise turning scores into decisions, the Fermi Problem Library has worked problems with a step-by-step solver that explains the reasoning rather than printing an answer.
Start with the eight scores above: draw the staircase, then count the 16 pairs.



