Skip to content
AI360XpertBeta
Core ML

Visual explainer

ROC and AUC

Sweep decision cutoffs to trace True Positive Rate against False Positive Rate, measuring threshold-independent ranking discrimination via Area Under the Curve.

ROC plots the fraction of negatives falsely alerted against the fraction of positives caught as the cutoff changes. AUC summarizes ranking across those cutoffs; it does not choose an operating policy or establish probability calibration.

A cutoff divides six scored cases into alerts and silence.
A cutoff divides six scored cases into alerts and silence.

Circles are actual positives P; squares are actual negatives N. The horizontal coordinate is a model score, with larger scores indicating stronger evidence for P. Our illustrative six cases, from high to low, are .9P, .8N, .7P, .6P, .4N, .2N. These scores happen to lie between zero and one; ROC also accepts unbounded decision scores. They need not be calibrated probabilities.

Predict positive when score is at least the cutoff. At .7, two circles and one square become alerts, including the circle exactly on the divider. One circle is missed. A threshold strictly above .9 alerts nobody. These conventions follow the official ROC API.

Normalize Within Each Class

Separate denominators give TPR two thirds and FPR one third.
Separate denominators give TPR two thirds and FPR one third.

The bars represent all three actual positives and all three actual negatives on the same count scale. Mint segments mark alerted members. At cutoff .7, true positives TP=2, false negatives FN=1, false positives FP=1 and true negatives TN=2.

True positive rate (TPR, also recall) is TP/(TP+FN)=2/3. False positive rate (FPR) is FP/(FP+TN)=1/3. Each denominator is a different actual class. Precision instead asks what fraction of all alerts are positive; that is 2/(2+1)=2/3 here, coincidentally equal to recall.

Walk The Cutoff Down

Positives move ROC up and negatives move it right.
Positives move ROC up and negatives move it right.

Both axes span zero to one. Start above .9 at (FPR,TPR)=(0,0), then admit cases in score order. Each positive contributes an upward step of 1/3; each negative contributes a rightward step of 1/3. Thresholds .9,.8,.7,.6,.4,.2 produce (0,1/3), (1/3,1/3), (1/3,2/3), (1/3,1), (2/3,1), (1,1). Consecutive vertical or horizontal steps share a straight segment.

This finite empirical curve is a staircase. It need not be smooth or convex. The dashed diagonal is the chance reference, with area .5; it is not an assertion that every realized random ranking falls exactly on that line.

Count Pairwise Wins

Seven of nine positive-negative pairs are correctly ordered.
Seven of nine positive-negative pairs are correctly ordered.

Compare each positive row against every negative column. A drawn check means the positive has the higher score; a cross means the negative does. The .9 positive wins three comparisons, .7 wins two, and .6 wins two: 7 wins among 9 pairs, giving AUC=7/9, approximately .778.

The same answer comes from ROC area: three horizontal strips have widths 1/3 and heights 1/3,1,1. Their areas sum to 1/9+1/3+1/3=7/9. AUC is the probability of a positive outranking a negative, with half credit for ties. This is ranking performance on the illustrated sample, not a claim about unseen data. See the evaluation guide.

Choose An Operating Policy

Lowering the cutoff from .9 to .6 catches two more positives and one negative.
Lowering the cutoff from .9 to .6 catches two more positives and one negative.

The circle at t=.9 catches one positive and no negatives: TPR=1/3,FPR=0. The square at t=.6 catches all three positives and one negative: TPR=1,FPR=1/3. The highlighted subpath shows precisely what the lower cutoff adds.

AUC stays 7/9 because the ranking stays fixed. Selecting a point requires the costs of misses and false alerts, review capacity and validation evidence. For example, minimizing a chosen empirical cost C_FP times FP plus C_FN times FN can favor different points. These six observations do not guarantee future rates.

Counts Depend On Prevalence

Equal conditional rates can yield very different alert precision.
Equal conditional rates can yield very different alert precision.

This controlled new example holds the positive pool at 30 and changes the negative pool from 30 to 300. Assume fixed class-conditional score distributions and the same cutoff, with TPR=2/3 and FPR=1/3. Both settings yield 20 true alerts; false alerts increase from 10 to 100. Both bars use three drawing units per case, so their total lengths represent 30 and 120 alerts.

Precision falls from 20/30=2/3 to 20/120=1/6. ROC is not intrinsically inflated by rarity: its conditional rates can stay fixed while alert workload changes. General distribution shifts can change ROC too. Pair ROC with precision-recall and actual counts when that workload matters; one operating point cannot determine either curve's area.

Ranking Is Not Calibration

Squaring scores preserves every rank while moving score magnitudes.
Squaring scores preserves every rank while moving score magnitudes.

The drawing tracks the three positive scores on two identical zero-to-one axes. Squaring maps .6,.7,.9 to .36,.49,.81; the negative scores .2,.4,.8 become .04,.16,.64. All nine positive-negative comparisons remain unchanged, so the ROC curve and AUC remain unchanged, while a fixed numeric cutoff may select different cases.

Squaring is strictly increasing on this fixture's nonnegative range. It is not rank-preserving over arbitrary signed scores. Neither score set's calibration can be determined from these ranks: calibration asks whether predicted probabilities match observed frequencies, requiring its own evaluation.

Give Ties Half Credit

A tied positive-negative pair earns half a ranking win.
A tied positive-negative pair earns half a ranking win.

This separate two-case fixture gives both P and N the score .5. Equal bar heights show that neither outranks the other. The credit square is half filled: AUC=P(s_positive>s_negative)+0.5 P(s_positive=s_negative).

The threshold sweep admits both together, joining (0,0) to (1,1). Standard linear interpolation across that tie produces area .5. Arbitrarily sorting tied items into a favorable order would invent discrimination that the scores do not provide.

Check The Score Direction

Reversing the score direction moves AUC from seven ninths to two ninths.
Reversing the score direction moves AUC from seven ninths to two ninths.

Each plot is a complete zero-to-one rate square with identical scales. The left uses the original scores. Negating every score reverses the order to N,N,P,P,N,P and produces the dashed right curve. Seven correct pair orders become two, so the new AUC is 2/9=1-7/9.

AUC ranges from zero to one, not from .5 to one. A result below .5 can indicate reversed score direction, reversed positive-class convention, or poor ranking. Diagnose the cause with held-out evidence rather than flipping a fitted evaluation after seeing its result.

Where It Breaks

Equal AUC can hide opposite choices at different false-alarm budgets.
Equal AUC can hide opposite choices at different false-alarm budgets.

A final small counterexample uses two positives and two negatives per model, with four distinct descending score ranks. Model A orders them P,N,N,P; model B orders them N,P,P,N. A wins 2+0 of four positive-negative pairs; B wins 1+1. Both have AUC=.5, yet their ROC paths cross.

The vertical dashed position is FPR=.5. Below that budget, A can catch half the positives without a false alert, while B catches none. At FPR=.5, B can catch all positives while A catches half. These are deterministic threshold operating points; randomizing decisions would require a separate policy. Equal total area fails to identify the best model within an operating region. Inspect the relevant region and its counts; report partial AUC when its convention and range match the question.

The Quick Version

  • A score becomes a verdict only after choosing a cutoff.
  • TPR and FPR normalize within different actual classes.
  • Positives move ROC up; negatives move it right.
  • Seven correct pairs among nine give AUC seven ninths.
  • The operating point adds costs and capacity to ranking evidence.
  • Fixed conditional rates can hide growing false-alert counts.
  • Rank-preserving transformations leave calibration questions unanswered.
  • Tied positive-negative pairs receive half credit.
  • Reversing score direction can drive AUC below one half.
  • Equal AUC can hide different performance within a budget.