ROC Curve
A scoring classifier gives each input a score , such as a predicted probability, and predicts positive when . The ROC curve (receiver operating characteristic) plots the true positive rate against the false positive rate. Each point belongs to one threshold, and sweeps from down to . The two rates are
TPR is the recall and FPR is one minus the specificity from the confusion matrix. The curve starts at , where nothing is flagged, and ends at , where everything is flagged. A perfect ranking passes through the top-left corner . A scorer that ignores the input follows the diagonal .On a test set with positives and negatives, the empirical curve takes four steps to build:
- Sort: order the test points by score, highest first.
- Start: place the first point at .
- Step: move up by for each positive and right by for each negative.
- Ties: move diagonally in one step through a group of tied scores that contains both classes.
The area under the curve (AUC, ROC-AUC, AUROC) summarizes the curve in one number. It equals the probability that a random positive outscores a random negative. Ties count as one half:
Here and are the scores of an independent random positive and random negative. The indicator is 1 when its condition holds. The double sum equals the Mann-Whitney statistic divided by .
- Range: AUC is 1 for a perfect ranking and 0.5 for a random one. A value below 0.5 means the scores are reversed, and negating them gives .
- Order only: any increasing transformation of the scores leaves the curve and the AUC unchanged.
- Class balance: AUC does not depend on the prevalence, because TPR and FPR are each computed within one class.
ROC-AUC is the default threshold-free measure of ranking quality. The precision-recall curve replaces it when positives are rare and only the top of the ranking matters.
Not Taught in Lecture
CS 182 lecture 1 reports AUC values in the pneumonia example and does not cover how the curve is built. The construction, the ranking interpretation and the cost analysis follow Fawcett (2006) and Hanley and McNeil (1982).
Intuition
The name comes from radar engineering in the Second World War. A radar operator chose how strong a blip had to be before calling it an enemy aircraft. A lower setting caught more aircraft and raised more false alarms. The curve of hits against false alarms over all settings described the receiver’s operating characteristic. A classifier’s score plays the role of the blip strength, and the threshold plays the role of the setting.
Each threshold gives one confusion matrix, and the ROC curve shows all of them at once. It therefore describes the scorer before anyone has chosen a threshold. Two models can be compared without first agreeing on the cost of each error. AUC also averages over thresholds that nobody will use. A screening program that can afford 2% false positives cares only about the left edge of the curve.
The animation passes the threshold over 40 scored points one at a time. Each positive moves the curve up by , and each negative moves it right by . The grid cells under the curve are the correctly ranked pairs, so AUC .
\usepackage{tikz}
\usetikzlibrary{animations, arrows.meta}
\begin{document}
\definecolor{hot}{HTML}{D9483B}
\definecolor{cold}{HTML}{2F80ED}
\definecolor{mid}{HTML}{8A8A8A}
\newcommand{\pf}[1]{\filldraw[draw=black, fill=hot] (#1) circle (2pt);}
\newcommand{\ph}[1]{\draw[hot, thick, fill=white] (#1) circle (1.8pt);}
\newcommand{\nf}[1]{\filldraw[draw=black, fill=cold] (#1) circle (2pt);}
\newcommand{\nh}[1]{\draw[cold, thick, fill=white] (#1) circle (1.8pt);}
\begin{tikzpicture}[font=\small, >={Stealth[length=2.2mm]}]
\draw (-0.10,1.15) -- (6.10,1.15);
\draw (0.00,1.08) -- (0.00,1.22) node[pos=0, below] {\footnotesize $0$};
\draw (3.00,1.08) -- (3.00,1.22) node[pos=0, below] {\footnotesize $0.5$};
\draw (6.00,1.08) -- (6.00,1.22) node[pos=0, below] {\footnotesize $1$};
\node at (3.00,0.43) {\footnotesize score $s$};
\node[anchor=east] at (-0.2,2.45) {$y = 1$};
\node[anchor=east] at (-0.2,1.75) {$y = 0$};
\draw (8.10,-1.40) rectangle (13.10,3.60);
\draw (8.10,-1.47) -- (8.10,-1.33) node[pos=0, below] {\footnotesize $0$};
\draw (8.03,-1.40) -- (8.17,-1.40) node[pos=0, left] {\footnotesize $0$};
\draw (10.60,-1.47) -- (10.60,-1.33) node[pos=0, below] {\footnotesize $0.5$};
\draw (8.03,1.10) -- (8.17,1.10) node[pos=0, left] {\footnotesize $0.5$};
\draw (13.10,-1.47) -- (13.10,-1.33) node[pos=0, below] {\footnotesize $1$};
\draw (8.03,3.60) -- (8.17,3.60) node[pos=0, left] {\footnotesize $1$};
\node at (10.60,-2.12) {false positive rate (FPR)};
\node[anchor=south] at (8.10,3.72) {true positive rate (TPR)};
\draw[mid, dashed, thick] (8.10,-1.40) -- (13.10,3.60);
\begin{scope}[animate = {myself: = {:visible = {0s = "true", 19.6s = "false", 29.8s = "false", repeats}}}]
\node[anchor=west] at (-0.95,-0.15) {TPR $= \mathrm{TP}/20$};
\node[anchor=west] at (-0.95,-0.7) {FPR $= \mathrm{FP}/20$};
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 19.6s = "true", 29.8s = "true", repeats}}}]
\draw[mid] (8.35,-1.40) -- (8.35,0.60) (8.60,-1.40) -- (8.60,0.85) (8.85,-1.40) -- (8.85,1.35) (9.10,-1.40) -- (9.10,1.85) (9.35,-1.40) -- (9.35,2.10) (9.60,-1.40) -- (9.60,2.35) (9.85,-1.40) -- (9.85,2.60) (10.10,-1.40) -- (10.10,2.85) (10.35,-1.40) -- (10.35,2.85) (10.60,-1.40) -- (10.60,3.10) (10.85,-1.40) -- (10.85,3.35) (11.10,-1.40) -- (11.10,3.35) (11.35,-1.40) -- (11.35,3.60) (11.60,-1.40) -- (11.60,3.60) (11.85,-1.40) -- (11.85,3.60) (12.10,-1.40) -- (12.10,3.60) (12.35,-1.40) -- (12.35,3.60) (12.60,-1.40) -- (12.60,3.60) (12.85,-1.40) -- (12.85,3.60) (8.10,-1.15) -- (13.10,-1.15) (8.10,-0.90) -- (13.10,-0.90) (8.10,-0.65) -- (13.10,-0.65) (8.10,-0.40) -- (13.10,-0.40) (8.10,-0.15) -- (13.10,-0.15) (8.10,0.10) -- (13.10,0.10) (8.10,0.35) -- (13.10,0.35) (8.10,0.60) -- (13.10,0.60) (8.35,0.85) -- (13.10,0.85) (8.60,1.10) -- (13.10,1.10) (8.60,1.35) -- (13.10,1.35) (8.85,1.60) -- (13.10,1.60) (8.85,1.85) -- (13.10,1.85) (9.10,2.10) -- (13.10,2.10) (9.35,2.35) -- (13.10,2.35) (9.60,2.60) -- (13.10,2.60) (9.85,2.85) -- (13.10,2.85) (10.35,3.10) -- (13.10,3.10) (10.60,3.35) -- (13.10,3.35);
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 2.2s = "true", 29.8s = "true", repeats}}}]
\draw[hot, line width=1.8pt] (8.10,-1.40) -- (8.10,-1.15);
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 2.4s = "true", 29.8s = "true", repeats}}}]
\draw[hot, line width=1.8pt] (8.10,-1.15) -- (8.10,-0.90);
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 2.6s = "true", 29.8s = "true", repeats}}}]
\draw[hot, line width=1.8pt] (8.10,-0.90) -- (8.10,-0.65);
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 2.8s = "true", 29.8s = "true", repeats}}}]
\draw[hot, line width=1.8pt] (8.10,-0.65) -- (8.10,-0.40);
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 3s = "true", 29.8s = "true", repeats}}}]
\draw[hot, line width=1.8pt] (8.10,-0.40) -- (8.10,-0.15);
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 3.2s = "true", 29.8s = "true", repeats}}}]
\draw[hot, line width=1.8pt] (8.10,-0.15) -- (8.10,0.10);
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 5.8s = "true", 29.8s = "true", repeats}}}]
\draw[hot, line width=1.8pt] (8.10,0.10) -- (8.10,0.35);
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 6s = "true", 29.8s = "true", repeats}}}]
\draw[hot, line width=1.8pt] (8.10,0.35) -- (8.10,0.60);
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 6.2s = "true", 29.8s = "true", repeats}}}]
\draw[cold, line width=1.8pt] (8.10,0.60) -- (8.35,0.60);
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 6.4s = "true", 29.8s = "true", repeats}}}]
\draw[hot, line width=1.8pt] (8.35,0.60) -- (8.35,0.85);
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 6.6s = "true", 29.8s = "true", repeats}}}]
\draw[cold, line width=1.8pt] (8.35,0.85) -- (8.60,0.85);
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 6.8s = "true", 29.8s = "true", repeats}}}]
\draw[hot, line width=1.8pt] (8.60,0.85) -- (8.60,1.10);
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 7s = "true", 29.8s = "true", repeats}}}]
\draw[hot, line width=1.8pt] (8.60,1.10) -- (8.60,1.35);
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 7.2s = "true", 29.8s = "true", repeats}}}]
\draw[cold, line width=1.8pt] (8.60,1.35) -- (8.85,1.35);
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 7.4s = "true", 29.8s = "true", repeats}}}]
\draw[hot, line width=1.8pt] (8.85,1.35) -- (8.85,1.60);
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 7.6s = "true", 29.8s = "true", repeats}}}]
\draw[hot, line width=1.8pt] (8.85,1.60) -- (8.85,1.85);
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 7.8s = "true", 29.8s = "true", repeats}}}]
\draw[cold, line width=1.8pt] (8.85,1.85) -- (9.10,1.85);
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 8s = "true", 29.8s = "true", repeats}}}]
\draw[hot, line width=1.8pt] (9.10,1.85) -- (9.10,2.10);
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 8.2s = "true", 29.8s = "true", repeats}}}]
\draw[cold, line width=1.8pt] (9.10,2.10) -- (9.35,2.10);
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 8.4s = "true", 29.8s = "true", repeats}}}]
\draw[hot, line width=1.8pt] (9.35,2.10) -- (9.35,2.35);
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 11s = "true", 29.8s = "true", repeats}}}]
\draw[cold, line width=1.8pt] (9.35,2.35) -- (9.60,2.35);
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 11.2s = "true", 29.8s = "true", repeats}}}]
\draw[hot, line width=1.8pt] (9.60,2.35) -- (9.60,2.60);
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 11.4s = "true", 29.8s = "true", repeats}}}]
\draw[cold, line width=1.8pt] (9.60,2.60) -- (9.85,2.60);
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 11.6s = "true", 29.8s = "true", repeats}}}]
\draw[hot, line width=1.8pt] (9.85,2.60) -- (9.85,2.85);
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 11.8s = "true", 29.8s = "true", repeats}}}]
\draw[cold, line width=1.8pt] (9.85,2.85) -- (10.10,2.85);
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 12s = "true", 29.8s = "true", repeats}}}]
\draw[cold, line width=1.8pt] (10.10,2.85) -- (10.35,2.85);
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 12.2s = "true", 29.8s = "true", repeats}}}]
\draw[hot, line width=1.8pt] (10.35,2.85) -- (10.35,3.10);
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 12.4s = "true", 29.8s = "true", repeats}}}]
\draw[cold, line width=1.8pt] (10.35,3.10) -- (10.60,3.10);
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 12.6s = "true", 29.8s = "true", repeats}}}]
\draw[hot, line width=1.8pt] (10.60,3.10) -- (10.60,3.35);
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 12.8s = "true", 29.8s = "true", repeats}}}]
\draw[cold, line width=1.8pt] (10.60,3.35) -- (10.85,3.35);
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 13s = "true", 29.8s = "true", repeats}}}]
\draw[cold, line width=1.8pt] (10.85,3.35) -- (11.10,3.35);
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 13.2s = "true", 29.8s = "true", repeats}}}]
\draw[hot, line width=1.8pt] (11.10,3.35) -- (11.10,3.60);
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 13.4s = "true", 29.8s = "true", repeats}}}]
\draw[cold, line width=1.8pt] (11.10,3.60) -- (11.35,3.60);
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 16s = "true", 29.8s = "true", repeats}}}]
\draw[cold, line width=1.8pt] (11.35,3.60) -- (11.60,3.60);
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 16.2s = "true", 29.8s = "true", repeats}}}]
\draw[cold, line width=1.8pt] (11.60,3.60) -- (11.85,3.60);
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 16.4s = "true", 29.8s = "true", repeats}}}]
\draw[cold, line width=1.8pt] (11.85,3.60) -- (12.10,3.60);
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 16.6s = "true", 29.8s = "true", repeats}}}]
\draw[cold, line width=1.8pt] (12.10,3.60) -- (12.35,3.60);
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 16.8s = "true", 29.8s = "true", repeats}}}]
\draw[cold, line width=1.8pt] (12.35,3.60) -- (12.60,3.60);
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 17s = "true", 29.8s = "true", repeats}}}]
\draw[cold, line width=1.8pt] (12.60,3.60) -- (12.85,3.60);
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 17.2s = "true", 29.8s = "true", repeats}}}]
\draw[cold, line width=1.8pt] (12.85,3.60) -- (13.10,3.60);
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "true", 2.2s = "false", 29.8s = "false", repeats}}}]
\draw[thick] (5.910,1.03) -- (5.910,2.87) node[above] {$t$};
\filldraw[draw=black, fill=black] (8.10,-1.40) circle (2.8pt);
\node[anchor=west] at (1.45,-0.15) {$= 0/20 = 0.00$};
\node[anchor=west] at (1.45,-0.7) {$= 0/20 = 0.00$};
\node[anchor=west] at (-0.95,-2.75) {Start above every score. Nothing is predicted positive, so the curve starts at $(0, 0)$.};
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 2.2s = "true", 2.4s = "false", 29.8s = "false", repeats}}}]
\draw[thick] (5.730,1.03) -- (5.730,2.87) node[above] {$t$};
\filldraw[draw=black, fill=black] (8.10,-1.15) circle (2.8pt);
\node[anchor=west] at (1.45,-0.15) {$= 1/20 = 0.05$};
\node[anchor=west] at (1.45,-0.7) {$= 0/20 = 0.00$};
\node[anchor=west] at (-0.95,-2.75) {A positive passes: the curve steps up by $1/20$.};
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 2.4s = "true", 2.6s = "false", 29.8s = "false", repeats}}}]
\draw[thick] (5.550,1.03) -- (5.550,2.87) node[above] {$t$};
\filldraw[draw=black, fill=black] (8.10,-0.90) circle (2.8pt);
\node[anchor=west] at (1.45,-0.15) {$= 2/20 = 0.10$};
\node[anchor=west] at (1.45,-0.7) {$= 0/20 = 0.00$};
\node[anchor=west] at (-0.95,-2.75) {A positive passes: the curve steps up by $1/20$.};
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 2.6s = "true", 2.8s = "false", 29.8s = "false", repeats}}}]
\draw[thick] (5.340,1.03) -- (5.340,2.87) node[above] {$t$};
\filldraw[draw=black, fill=black] (8.10,-0.65) circle (2.8pt);
\node[anchor=west] at (1.45,-0.15) {$= 3/20 = 0.15$};
\node[anchor=west] at (1.45,-0.7) {$= 0/20 = 0.00$};
\node[anchor=west] at (-0.95,-2.75) {A positive passes: the curve steps up by $1/20$.};
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 2.8s = "true", 3s = "false", 29.8s = "false", repeats}}}]
\draw[thick] (5.130,1.03) -- (5.130,2.87) node[above] {$t$};
\filldraw[draw=black, fill=black] (8.10,-0.40) circle (2.8pt);
\node[anchor=west] at (1.45,-0.15) {$= 4/20 = 0.20$};
\node[anchor=west] at (1.45,-0.7) {$= 0/20 = 0.00$};
\node[anchor=west] at (-0.95,-2.75) {A positive passes: the curve steps up by $1/20$.};
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 3s = "true", 3.2s = "false", 29.8s = "false", repeats}}}]
\draw[thick] (4.950,1.03) -- (4.950,2.87) node[above] {$t$};
\filldraw[draw=black, fill=black] (8.10,-0.15) circle (2.8pt);
\node[anchor=west] at (1.45,-0.15) {$= 5/20 = 0.25$};
\node[anchor=west] at (1.45,-0.7) {$= 0/20 = 0.00$};
\node[anchor=west] at (-0.95,-2.75) {A positive passes: the curve steps up by $1/20$.};
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 3.2s = "true", 5.8s = "false", 29.8s = "false", repeats}}}]
\draw[thick] (4.740,1.03) -- (4.740,2.87) node[above] {$t$};
\filldraw[draw=black, fill=black] (8.10,0.10) circle (2.8pt);
\node[anchor=west] at (1.45,-0.15) {$= 6/20 = 0.30$};
\node[anchor=west] at (1.45,-0.7) {$= 0/20 = 0.00$};
\node[anchor=west] at (-0.95,-2.75) {High threshold: TPR is $0.30$ and FPR is $0$. Every flagged point is positive.};
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 5.8s = "true", 6s = "false", 29.8s = "false", repeats}}}]
\draw[thick] (4.530,1.03) -- (4.530,2.87) node[above] {$t$};
\filldraw[draw=black, fill=black] (8.10,0.35) circle (2.8pt);
\node[anchor=west] at (1.45,-0.15) {$= 7/20 = 0.35$};
\node[anchor=west] at (1.45,-0.7) {$= 0/20 = 0.00$};
\node[anchor=west] at (-0.95,-2.75) {A positive passes: the curve steps up by $1/20$.};
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 6s = "true", 6.2s = "false", 29.8s = "false", repeats}}}]
\draw[thick] (4.410,1.03) -- (4.410,2.87) node[above] {$t$};
\filldraw[draw=black, fill=black] (8.10,0.60) circle (2.8pt);
\node[anchor=west] at (1.45,-0.15) {$= 8/20 = 0.40$};
\node[anchor=west] at (1.45,-0.7) {$= 0/20 = 0.00$};
\node[anchor=west] at (-0.95,-2.75) {A positive passes: the curve steps up by $1/20$.};
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 6.2s = "true", 6.4s = "false", 29.8s = "false", repeats}}}]
\draw[thick] (4.320,1.03) -- (4.320,2.87) node[above] {$t$};
\filldraw[draw=black, fill=black] (8.35,0.60) circle (2.8pt);
\node[anchor=west] at (1.45,-0.15) {$= 8/20 = 0.40$};
\node[anchor=west] at (1.45,-0.7) {$= 1/20 = 0.05$};
\node[anchor=west] at (-0.95,-2.75) {A negative passes: the curve steps right by $1/20$.};
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 6.4s = "true", 6.6s = "false", 29.8s = "false", repeats}}}]
\draw[thick] (4.170,1.03) -- (4.170,2.87) node[above] {$t$};
\filldraw[draw=black, fill=black] (8.35,0.85) circle (2.8pt);
\node[anchor=west] at (1.45,-0.15) {$= 9/20 = 0.45$};
\node[anchor=west] at (1.45,-0.7) {$= 1/20 = 0.05$};
\node[anchor=west] at (-0.95,-2.75) {A positive passes: the curve steps up by $1/20$.};
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 6.6s = "true", 6.8s = "false", 29.8s = "false", repeats}}}]
\draw[thick] (4.050,1.03) -- (4.050,2.87) node[above] {$t$};
\filldraw[draw=black, fill=black] (8.60,0.85) circle (2.8pt);
\node[anchor=west] at (1.45,-0.15) {$= 9/20 = 0.45$};
\node[anchor=west] at (1.45,-0.7) {$= 2/20 = 0.10$};
\node[anchor=west] at (-0.95,-2.75) {A negative passes: the curve steps right by $1/20$.};
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 6.8s = "true", 7s = "false", 29.8s = "false", repeats}}}]
\draw[thick] (3.930,1.03) -- (3.930,2.87) node[above] {$t$};
\filldraw[draw=black, fill=black] (8.60,1.10) circle (2.8pt);
\node[anchor=west] at (1.45,-0.15) {$= 10/20 = 0.50$};
\node[anchor=west] at (1.45,-0.7) {$= 2/20 = 0.10$};
\node[anchor=west] at (-0.95,-2.75) {A positive passes: the curve steps up by $1/20$.};
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 7s = "true", 7.2s = "false", 29.8s = "false", repeats}}}]
\draw[thick] (3.780,1.03) -- (3.780,2.87) node[above] {$t$};
\filldraw[draw=black, fill=black] (8.60,1.35) circle (2.8pt);
\node[anchor=west] at (1.45,-0.15) {$= 11/20 = 0.55$};
\node[anchor=west] at (1.45,-0.7) {$= 2/20 = 0.10$};
\node[anchor=west] at (-0.95,-2.75) {A positive passes: the curve steps up by $1/20$.};
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 7.2s = "true", 7.4s = "false", 29.8s = "false", repeats}}}]
\draw[thick] (3.690,1.03) -- (3.690,2.87) node[above] {$t$};
\filldraw[draw=black, fill=black] (8.85,1.35) circle (2.8pt);
\node[anchor=west] at (1.45,-0.15) {$= 11/20 = 0.55$};
\node[anchor=west] at (1.45,-0.7) {$= 3/20 = 0.15$};
\node[anchor=west] at (-0.95,-2.75) {A negative passes: the curve steps right by $1/20$.};
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 7.4s = "true", 7.6s = "false", 29.8s = "false", repeats}}}]
\draw[thick] (3.570,1.03) -- (3.570,2.87) node[above] {$t$};
\filldraw[draw=black, fill=black] (8.85,1.60) circle (2.8pt);
\node[anchor=west] at (1.45,-0.15) {$= 12/20 = 0.60$};
\node[anchor=west] at (1.45,-0.7) {$= 3/20 = 0.15$};
\node[anchor=west] at (-0.95,-2.75) {A positive passes: the curve steps up by $1/20$.};
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 7.6s = "true", 7.8s = "false", 29.8s = "false", repeats}}}]
\draw[thick] (3.420,1.03) -- (3.420,2.87) node[above] {$t$};
\filldraw[draw=black, fill=black] (8.85,1.85) circle (2.8pt);
\node[anchor=west] at (1.45,-0.15) {$= 13/20 = 0.65$};
\node[anchor=west] at (1.45,-0.7) {$= 3/20 = 0.15$};
\node[anchor=west] at (-0.95,-2.75) {A positive passes: the curve steps up by $1/20$.};
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 7.8s = "true", 8s = "false", 29.8s = "false", repeats}}}]
\draw[thick] (3.300,1.03) -- (3.300,2.87) node[above] {$t$};
\filldraw[draw=black, fill=black] (9.10,1.85) circle (2.8pt);
\node[anchor=west] at (1.45,-0.15) {$= 13/20 = 0.65$};
\node[anchor=west] at (1.45,-0.7) {$= 4/20 = 0.20$};
\node[anchor=west] at (-0.95,-2.75) {A negative passes: the curve steps right by $1/20$.};
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 8s = "true", 8.2s = "false", 29.8s = "false", repeats}}}]
\draw[thick] (3.210,1.03) -- (3.210,2.87) node[above] {$t$};
\filldraw[draw=black, fill=black] (9.10,2.10) circle (2.8pt);
\node[anchor=west] at (1.45,-0.15) {$= 14/20 = 0.70$};
\node[anchor=west] at (1.45,-0.7) {$= 4/20 = 0.20$};
\node[anchor=west] at (-0.95,-2.75) {A positive passes: the curve steps up by $1/20$.};
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 8.2s = "true", 8.4s = "false", 29.8s = "false", repeats}}}]
\draw[thick] (3.120,1.03) -- (3.120,2.87) node[above] {$t$};
\filldraw[draw=black, fill=black] (9.35,2.10) circle (2.8pt);
\node[anchor=west] at (1.45,-0.15) {$= 14/20 = 0.70$};
\node[anchor=west] at (1.45,-0.7) {$= 5/20 = 0.25$};
\node[anchor=west] at (-0.95,-2.75) {A negative passes: the curve steps right by $1/20$.};
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 8.4s = "true", 11s = "false", 29.8s = "false", repeats}}}]
\draw[thick] (3.000,1.03) -- (3.000,2.87) node[above] {$t$};
\filldraw[draw=black, fill=black] (9.35,2.35) circle (2.8pt);
\node[anchor=west] at (1.45,-0.15) {$= 15/20 = 0.75$};
\node[anchor=west] at (1.45,-0.7) {$= 5/20 = 0.25$};
\node[anchor=west] at (-0.95,-2.75) {Middle threshold: TPR is $0.75$ and FPR is $0.25$.};
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 11s = "true", 11.2s = "false", 29.8s = "false", repeats}}}]
\draw[thick] (2.880,1.03) -- (2.880,2.87) node[above] {$t$};
\filldraw[draw=black, fill=black] (9.60,2.35) circle (2.8pt);
\node[anchor=west] at (1.45,-0.15) {$= 15/20 = 0.75$};
\node[anchor=west] at (1.45,-0.7) {$= 6/20 = 0.30$};
\node[anchor=west] at (-0.95,-2.75) {A negative passes: the curve steps right by $1/20$.};
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 11.2s = "true", 11.4s = "false", 29.8s = "false", repeats}}}]
\draw[thick] (2.790,1.03) -- (2.790,2.87) node[above] {$t$};
\filldraw[draw=black, fill=black] (9.60,2.60) circle (2.8pt);
\node[anchor=west] at (1.45,-0.15) {$= 16/20 = 0.80$};
\node[anchor=west] at (1.45,-0.7) {$= 6/20 = 0.30$};
\node[anchor=west] at (-0.95,-2.75) {A positive passes: the curve steps up by $1/20$.};
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 11.4s = "true", 11.6s = "false", 29.8s = "false", repeats}}}]
\draw[thick] (2.670,1.03) -- (2.670,2.87) node[above] {$t$};
\filldraw[draw=black, fill=black] (9.85,2.60) circle (2.8pt);
\node[anchor=west] at (1.45,-0.15) {$= 16/20 = 0.80$};
\node[anchor=west] at (1.45,-0.7) {$= 7/20 = 0.35$};
\node[anchor=west] at (-0.95,-2.75) {A negative passes: the curve steps right by $1/20$.};
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 11.6s = "true", 11.8s = "false", 29.8s = "false", repeats}}}]
\draw[thick] (2.550,1.03) -- (2.550,2.87) node[above] {$t$};
\filldraw[draw=black, fill=black] (9.85,2.85) circle (2.8pt);
\node[anchor=west] at (1.45,-0.15) {$= 17/20 = 0.85$};
\node[anchor=west] at (1.45,-0.7) {$= 7/20 = 0.35$};
\node[anchor=west] at (-0.95,-2.75) {A positive passes: the curve steps up by $1/20$.};
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 11.8s = "true", 12s = "false", 29.8s = "false", repeats}}}]
\draw[thick] (2.430,1.03) -- (2.430,2.87) node[above] {$t$};
\filldraw[draw=black, fill=black] (10.10,2.85) circle (2.8pt);
\node[anchor=west] at (1.45,-0.15) {$= 17/20 = 0.85$};
\node[anchor=west] at (1.45,-0.7) {$= 8/20 = 0.40$};
\node[anchor=west] at (-0.95,-2.75) {A negative passes: the curve steps right by $1/20$.};
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 12s = "true", 12.2s = "false", 29.8s = "false", repeats}}}]
\draw[thick] (2.310,1.03) -- (2.310,2.87) node[above] {$t$};
\filldraw[draw=black, fill=black] (10.35,2.85) circle (2.8pt);
\node[anchor=west] at (1.45,-0.15) {$= 17/20 = 0.85$};
\node[anchor=west] at (1.45,-0.7) {$= 9/20 = 0.45$};
\node[anchor=west] at (-0.95,-2.75) {A negative passes: the curve steps right by $1/20$.};
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 12.2s = "true", 12.4s = "false", 29.8s = "false", repeats}}}]
\draw[thick] (2.220,1.03) -- (2.220,2.87) node[above] {$t$};
\filldraw[draw=black, fill=black] (10.35,3.10) circle (2.8pt);
\node[anchor=west] at (1.45,-0.15) {$= 18/20 = 0.90$};
\node[anchor=west] at (1.45,-0.7) {$= 9/20 = 0.45$};
\node[anchor=west] at (-0.95,-2.75) {A positive passes: the curve steps up by $1/20$.};
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 12.4s = "true", 12.6s = "false", 29.8s = "false", repeats}}}]
\draw[thick] (2.100,1.03) -- (2.100,2.87) node[above] {$t$};
\filldraw[draw=black, fill=black] (10.60,3.10) circle (2.8pt);
\node[anchor=west] at (1.45,-0.15) {$= 18/20 = 0.90$};
\node[anchor=west] at (1.45,-0.7) {$= 10/20 = 0.50$};
\node[anchor=west] at (-0.95,-2.75) {A negative passes: the curve steps right by $1/20$.};
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 12.6s = "true", 12.8s = "false", 29.8s = "false", repeats}}}]
\draw[thick] (1.980,1.03) -- (1.980,2.87) node[above] {$t$};
\filldraw[draw=black, fill=black] (10.60,3.35) circle (2.8pt);
\node[anchor=west] at (1.45,-0.15) {$= 19/20 = 0.95$};
\node[anchor=west] at (1.45,-0.7) {$= 10/20 = 0.50$};
\node[anchor=west] at (-0.95,-2.75) {A positive passes: the curve steps up by $1/20$.};
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 12.8s = "true", 13s = "false", 29.8s = "false", repeats}}}]
\draw[thick] (1.830,1.03) -- (1.830,2.87) node[above] {$t$};
\filldraw[draw=black, fill=black] (10.85,3.35) circle (2.8pt);
\node[anchor=west] at (1.45,-0.15) {$= 19/20 = 0.95$};
\node[anchor=west] at (1.45,-0.7) {$= 11/20 = 0.55$};
\node[anchor=west] at (-0.95,-2.75) {A negative passes: the curve steps right by $1/20$.};
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 13s = "true", 13.2s = "false", 29.8s = "false", repeats}}}]
\draw[thick] (1.680,1.03) -- (1.680,2.87) node[above] {$t$};
\filldraw[draw=black, fill=black] (11.10,3.35) circle (2.8pt);
\node[anchor=west] at (1.45,-0.15) {$= 19/20 = 0.95$};
\node[anchor=west] at (1.45,-0.7) {$= 12/20 = 0.60$};
\node[anchor=west] at (-0.95,-2.75) {A negative passes: the curve steps right by $1/20$.};
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 13.2s = "true", 13.4s = "false", 29.8s = "false", repeats}}}]
\draw[thick] (1.590,1.03) -- (1.590,2.87) node[above] {$t$};
\filldraw[draw=black, fill=black] (11.10,3.60) circle (2.8pt);
\node[anchor=west] at (1.45,-0.15) {$= 20/20 = 1.00$};
\node[anchor=west] at (1.45,-0.7) {$= 12/20 = 0.60$};
\node[anchor=west] at (-0.95,-2.75) {A positive passes: the curve steps up by $1/20$.};
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 13.4s = "true", 16s = "false", 29.8s = "false", repeats}}}]
\draw[thick] (1.440,1.03) -- (1.440,2.87) node[above] {$t$};
\filldraw[draw=black, fill=black] (11.35,3.60) circle (2.8pt);
\node[anchor=west] at (1.45,-0.15) {$= 20/20 = 1.00$};
\node[anchor=west] at (1.45,-0.7) {$= 13/20 = 0.65$};
\node[anchor=west] at (-0.95,-2.75) {The last positive passes: TPR reaches $1$ at FPR $0.65$.};
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 16s = "true", 16.2s = "false", 29.8s = "false", repeats}}}]
\draw[thick] (1.230,1.03) -- (1.230,2.87) node[above] {$t$};
\filldraw[draw=black, fill=black] (11.60,3.60) circle (2.8pt);
\node[anchor=west] at (1.45,-0.15) {$= 20/20 = 1.00$};
\node[anchor=west] at (1.45,-0.7) {$= 14/20 = 0.70$};
\node[anchor=west] at (-0.95,-2.75) {A negative passes: the curve steps right by $1/20$.};
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 16.2s = "true", 16.4s = "false", 29.8s = "false", repeats}}}]
\draw[thick] (1.050,1.03) -- (1.050,2.87) node[above] {$t$};
\filldraw[draw=black, fill=black] (11.85,3.60) circle (2.8pt);
\node[anchor=west] at (1.45,-0.15) {$= 20/20 = 1.00$};
\node[anchor=west] at (1.45,-0.7) {$= 15/20 = 0.75$};
\node[anchor=west] at (-0.95,-2.75) {A negative passes: the curve steps right by $1/20$.};
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 16.4s = "true", 16.6s = "false", 29.8s = "false", repeats}}}]
\draw[thick] (0.840,1.03) -- (0.840,2.87) node[above] {$t$};
\filldraw[draw=black, fill=black] (12.10,3.60) circle (2.8pt);
\node[anchor=west] at (1.45,-0.15) {$= 20/20 = 1.00$};
\node[anchor=west] at (1.45,-0.7) {$= 16/20 = 0.80$};
\node[anchor=west] at (-0.95,-2.75) {A negative passes: the curve steps right by $1/20$.};
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 16.6s = "true", 16.8s = "false", 29.8s = "false", repeats}}}]
\draw[thick] (0.630,1.03) -- (0.630,2.87) node[above] {$t$};
\filldraw[draw=black, fill=black] (12.35,3.60) circle (2.8pt);
\node[anchor=west] at (1.45,-0.15) {$= 20/20 = 1.00$};
\node[anchor=west] at (1.45,-0.7) {$= 17/20 = 0.85$};
\node[anchor=west] at (-0.95,-2.75) {A negative passes: the curve steps right by $1/20$.};
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 16.8s = "true", 17s = "false", 29.8s = "false", repeats}}}]
\draw[thick] (0.450,1.03) -- (0.450,2.87) node[above] {$t$};
\filldraw[draw=black, fill=black] (12.60,3.60) circle (2.8pt);
\node[anchor=west] at (1.45,-0.15) {$= 20/20 = 1.00$};
\node[anchor=west] at (1.45,-0.7) {$= 18/20 = 0.90$};
\node[anchor=west] at (-0.95,-2.75) {A negative passes: the curve steps right by $1/20$.};
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 17s = "true", 17.2s = "false", 29.8s = "false", repeats}}}]
\draw[thick] (0.240,1.03) -- (0.240,2.87) node[above] {$t$};
\filldraw[draw=black, fill=black] (12.85,3.60) circle (2.8pt);
\node[anchor=west] at (1.45,-0.15) {$= 20/20 = 1.00$};
\node[anchor=west] at (1.45,-0.7) {$= 19/20 = 0.95$};
\node[anchor=west] at (-0.95,-2.75) {A negative passes: the curve steps right by $1/20$.};
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 17.2s = "true", 19.6s = "false", 29.8s = "false", repeats}}}]
\draw[thick] (0.060,1.03) -- (0.060,2.87) node[above] {$t$};
\filldraw[draw=black, fill=black] (13.10,3.60) circle (2.8pt);
\node[anchor=west] at (1.45,-0.15) {$= 20/20 = 1.00$};
\node[anchor=west] at (1.45,-0.7) {$= 20/20 = 1.00$};
\node[anchor=west] at (-0.95,-2.75) {Below every score, every point is predicted positive. The curve ends at $(1, 1)$.};
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 19.6s = "true", 22.6s = "false", 29.8s = "false", repeats}}}]
\draw[line width=1.6pt] (9.85,-0.40) rectangle (10.10,-0.15);
\draw[->, very thick] (5.04,3.07) -- (5.04,2.58);
\draw[->, very thick] (2.52,1.20) -- (2.52,1.62);
\node[anchor=west] at (-0.95,-0.15) {positive $0.84$ is the $5$th highest: row $5$};
\node[anchor=west] at (-0.95,-0.7) {negative $0.42$ is the $8$th highest: column $8$};
\node[anchor=west] at (-0.95,-2.75) {The positive outscores the negative, so their cell lies under the curve.};
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 22.6s = "true", 25.6s = "false", 29.8s = "false", repeats}}}]
\draw[line width=1.6pt] (8.10,0.60) rectangle (8.35,0.85);
\draw[->, very thick] (4.26,3.07) -- (4.26,2.58);
\draw[->, very thick] (4.38,1.20) -- (4.38,1.62);
\node[anchor=west] at (-0.95,-0.15) {positive $0.71$ is the $9$th highest: row $9$};
\node[anchor=west] at (-0.95,-0.7) {negative $0.73$ is the $1$st highest: column $1$};
\node[anchor=west] at (-0.95,-2.75) {The negative outscores the positive, so their cell lies above the curve.};
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 25.6s = "true", 29.8s = "false", 29.8s = "false", repeats}}}]
\node[anchor=west] at (-0.95,-0.15) {area under the curve: AUC $= 0.84$};
\node[anchor=west] at (-0.95,-0.7) {pairs ranked correctly: $336/400 = 0.84$};
\node[anchor=west] at (-0.95,-2.75) {Each grid cell is one positive-negative pair. Cells under the curve are ranked correctly.};
\end{scope}
\begin{scope}[]
\ph{1.62,2.45} \ph{2.04,2.45} \ph{2.28,2.45} \ph{2.58,2.45} \ph{2.82,2.45} \ph{3.06,2.45} \ph{3.24,2.45} \ph{3.48,2.45} \ph{3.66,2.45} \ph{3.84,2.45} \ph{4.02,2.45} \ph{4.26,2.45} \ph{4.44,2.45} \ph{4.62,2.45} \ph{4.86,2.45} \ph{5.04,2.45} \ph{5.22,2.45} \ph{5.46,2.45} \ph{5.64,2.45} \ph{5.82,2.45}
\nh{0.12,1.75} \nh{0.36,1.75} \nh{0.54,1.75} \nh{0.72,1.75} \nh{0.96,1.75} \nh{1.14,1.75} \nh{1.32,1.75} \nh{1.56,1.75} \nh{1.74,1.75} \nh{1.92,1.75} \nh{2.16,1.75} \nh{2.34,1.75} \nh{2.52,1.75} \nh{2.76,1.75} \nh{2.94,1.75} \nh{3.18,1.75} \nh{3.36,1.75} \nh{3.72,1.75} \nh{4.08,1.75} \nh{4.38,1.75}
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 2.2s = "true", 29.8s = "true", repeats}}}]
\pf{5.82,2.45}
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 2.4s = "true", 29.8s = "true", repeats}}}]
\pf{5.64,2.45}
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 2.6s = "true", 29.8s = "true", repeats}}}]
\pf{5.46,2.45}
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 2.8s = "true", 29.8s = "true", repeats}}}]
\pf{5.22,2.45}
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 3s = "true", 29.8s = "true", repeats}}}]
\pf{5.04,2.45}
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 3.2s = "true", 29.8s = "true", repeats}}}]
\pf{4.86,2.45}
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 5.8s = "true", 29.8s = "true", repeats}}}]
\pf{4.62,2.45}
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 6s = "true", 29.8s = "true", repeats}}}]
\pf{4.44,2.45}
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 6.2s = "true", 29.8s = "true", repeats}}}]
\nf{4.38,1.75}
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 6.4s = "true", 29.8s = "true", repeats}}}]
\pf{4.26,2.45}
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 6.6s = "true", 29.8s = "true", repeats}}}]
\nf{4.08,1.75}
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 6.8s = "true", 29.8s = "true", repeats}}}]
\pf{4.02,2.45}
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 7s = "true", 29.8s = "true", repeats}}}]
\pf{3.84,2.45}
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 7.2s = "true", 29.8s = "true", repeats}}}]
\nf{3.72,1.75}
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 7.4s = "true", 29.8s = "true", repeats}}}]
\pf{3.66,2.45}
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 7.6s = "true", 29.8s = "true", repeats}}}]
\pf{3.48,2.45}
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 7.8s = "true", 29.8s = "true", repeats}}}]
\nf{3.36,1.75}
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 8s = "true", 29.8s = "true", repeats}}}]
\pf{3.24,2.45}
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 8.2s = "true", 29.8s = "true", repeats}}}]
\nf{3.18,1.75}
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 8.4s = "true", 29.8s = "true", repeats}}}]
\pf{3.06,2.45}
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 11s = "true", 29.8s = "true", repeats}}}]
\nf{2.94,1.75}
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 11.2s = "true", 29.8s = "true", repeats}}}]
\pf{2.82,2.45}
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 11.4s = "true", 29.8s = "true", repeats}}}]
\nf{2.76,1.75}
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 11.6s = "true", 29.8s = "true", repeats}}}]
\pf{2.58,2.45}
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 11.8s = "true", 29.8s = "true", repeats}}}]
\nf{2.52,1.75}
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 12s = "true", 29.8s = "true", repeats}}}]
\nf{2.34,1.75}
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 12.2s = "true", 29.8s = "true", repeats}}}]
\pf{2.28,2.45}
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 12.4s = "true", 29.8s = "true", repeats}}}]
\nf{2.16,1.75}
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 12.6s = "true", 29.8s = "true", repeats}}}]
\pf{2.04,2.45}
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 12.8s = "true", 29.8s = "true", repeats}}}]
\nf{1.92,1.75}
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 13s = "true", 29.8s = "true", repeats}}}]
\nf{1.74,1.75}
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 13.2s = "true", 29.8s = "true", repeats}}}]
\pf{1.62,2.45}
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 13.4s = "true", 29.8s = "true", repeats}}}]
\nf{1.56,1.75}
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 16s = "true", 29.8s = "true", repeats}}}]
\nf{1.32,1.75}
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 16.2s = "true", 29.8s = "true", repeats}}}]
\nf{1.14,1.75}
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 16.4s = "true", 29.8s = "true", repeats}}}]
\nf{0.96,1.75}
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 16.6s = "true", 29.8s = "true", repeats}}}]
\nf{0.72,1.75}
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 16.8s = "true", 29.8s = "true", repeats}}}]
\nf{0.54,1.75}
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 17s = "true", 29.8s = "true", repeats}}}]
\nf{0.36,1.75}
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 17.2s = "true", 29.8s = "true", repeats}}}]
\nf{0.12,1.75}
\end{scope}
\node[fill=white, inner sep=1.5pt, rotate=45] at (12.05,2.15) {\footnotesize chance};
\end{tikzpicture}
\end{document}Properties
(AUC Ignores Calibration) Two models with the same ranking have the same ROC curve, even if one of them outputs badly wrong probabilities.
Multiplying every predicted probability by 0.1 keeps the order of the scores. So does squeezing all of them toward 0.5. The AUC stays the same in both cases. A model with AUC 0.95 can still predict 0.9 for patients whose true risk is 0.3. Some probabilities feed a decision, such as the price of a loan. Check those with log loss or a reliability diagram. For the same reason, scores on different scales can be compared by AUC directly. Margins from a support vector machine and vote fractions from a random forest need no conversion.
(Insensitive to Class Balance) The ROC curve stays fixed when the class balance changes, as long as each class keeps its distribution of scores.
Suppose a disease falls from 10% to 1% of patients. Sick and healthy patients keep their score distributions. TPR is computed among sick patients only, and FPR among healthy patients only, so neither changes. AUC values from hospitals with different prevalence are therefore comparable. The same invariance hides the number of false alarms. When negatives outnumber positives a thousand to one, a small FPR still produces many more false alarms than true positives. The precision-recall curve makes that cost visible (Saito and Rehmsmeier 2015).
(Pooled AUC Can Reward a Shortcut) On data pooled from several sites, a model can earn a high AUC by recognizing the site.
CS 182 lecture 1 presents the study of Zech et al. (2018). The study used chest X-rays from three hospital systems. A CNN trained on two of them detected pneumonia with AUC 0.93 on held-out images from those two. On the third, unseen system its AUC fell to 0.82. The network could identify the source hospital with over 99.9% accuracy from scanner signatures, patient positioning and text overlays. Pneumonia prevalence differed sharply across sites, 34% at one and about 1% at another. A model that ignored the image and used only hospital identity reached AUC 0.86 on the pooled internal test set. Pooled AUC compares positives from the high-prevalence site with negatives from the low-prevalence site. Site identity alone orders many such pairs correctly. Compute AUC within each site as well, and split test data by the unit of deployment, as 2.3. Generalization explains.
(Choosing an Operating Point) With known costs and prevalence, the best threshold lies where a line of slope touches the ROC curve.
Let be the cost of a miss and the cost of a false alarm. The expected cost per case at a threshold is
where is the prevalence. All points with equal cost lie on a straight line of slope in ROC space. Slide such a line down from the top-left corner. The first point of the curve it touches has the lowest cost. Rare positives or cheap misses make large, which pushes the operating point toward low FPR. With the rule maximizes Youden’s index . Only points on the convex hull of the curve can be optimal for some costs. Randomizing between the thresholds of two hull points reaches any point on the segment between them (Provost and Fawcett 2001).
(Crossing Curves) Two ROC curves with equal AUC can cross, and then each model wins over part of the FPR range.
An analyst then cannot pick a model for a fixed range of thresholds from the total area alone. A screening program limited to 5% false positives should compare the curves only over . The partial AUC over that range does this (McClish 1989). A random scorer has partial AUC over , which is 0.00125 for . Report a partial AUC next to that baseline. The Neyman-Pearson lemma states that thresholding the likelihood ratio gives the highest TPR at every FPR. The best possible ROC curve therefore belongs to the true likelihood ratio, as 1.4.1 Neyman-Pearson Testing shows.
Derivation
We show that the area under the ROC curve equals for continuous scores. Let be the density of the negative scores. As falls from to , rises from 0 to 1, and . The area is
The last integral averages over drawn from the negative scores. It therefore equals , and ties have probability zero for continuous scores.
On a finite test set the same argument counts rectangles. Each negative moves the curve right by at height . Summing these rectangles gives the double sum in the definition. A tie between a positive and a negative creates a diagonal segment, which contributes half a rectangle.
A common model takes Gaussian scores with equal variance in both classes and means that differ by . Then has distribution , and
where is the standard normal CDF. Means one standard deviation apart give AUC 0.76, and two apart give 0.92. Under this model, the internal AUC of 0.93 in the pneumonia study matches . The new-hospital AUC of 0.82 matches 1.29.
Examples
(Easy) ROC Curve for Eight Emails
A spam filter scores eight emails. The four spam emails get 0.95, 0.85, 0.60 and 0.40. The four legitimate emails get 0.70, 0.30, 0.20 and 0.10.
Trace the ROC curve and compute the AUC in two ways. , and each legitimate one moves it right by . The curve visits , , , , , , , and . The area under this staircase is . Counting pairs gives the same answer. The spam emails at 0.95 and 0.85 outrank all four legitimate ones. Those at 0.60 and 0.40 outrank three each. That makes of 16 pairs, and . A threshold of 0.35 catches all spam at , the point .
Write S for spam and L for legitimate. Sorted by score, the labels read S, S, L, S, S, L, L, L. Each spam email moves the curve up by
(Medium) An AUC From Hospital Identity Alone
Hospital A sends 1,000 chest X-rays to a test set, and hospital B sends 2,500. Pneumonia prevalence is 34% at A and 1% at B. A model ignores the image. It outputs 1 for every X-ray from hospital A and 0 for every X-ray from hospital B.
What is the model's AUC on the pooled test set, and within each hospital? positives and negatives. A random positive comes from A with probability . A random negative comes from B with probability . The model ranks the positive higher only when the positive is from A and the negative is from B. This happens with probability . Ties occur when both come from the same hospital, with probability . The AUC is , the value Zech et al. reported for their hospital-only model. Within either hospital every score is the same, so the AUC is exactly 0.5. The pooled value measures the difference in prevalence between the sites and nothing about the lungs. It also depends on the mix of sites. With 1,000 X-rays from each hospital, the same model scores 0.786.
The pooled set has
(Hard) Picking a Screening Threshold
A screening test for a disease with 2% prevalence offers five thresholds. Their ROC points are , , , and . A false positive leads to a follow-up exam that costs 1 unit. A missed case costs 50 units.
Which threshold minimizes the expected cost per person? How does the answer change if a miss costs 100 units? . The five points cost 0.520, 0.349, 0.248, 0.266 and 0.412, so is best. The iso-cost slope is . The segment into has slope 3, steeper than . The segment out of it has slope 0.8, flatter than . This is the tangency condition. If a miss costs 100 units, the cost becomes . The five points then cost 1.020, 0.649, 0.398, 0.336 and 0.432. The best point moves to , where lies between the neighboring slopes 0.8 and 0.25. Costlier misses push the operating point up and to the right.
The expected cost per person is
See Also
- 2.2.1. Confusion Matrix, for TPR and FPR at a single threshold.
- 2.2.3. Precision-Recall Curve, the alternative when positives are rare.
- 2.2.4. Log Loss, for the quality of the probabilities, which AUC ignores.
- 2.3. Generalization, for splitting test data by hospital or patient.
- 1.4.1 Neyman-Pearson Testing, where TPR is the power of a test and FPR its significance level.