ROC Curves &
AUC
Learn how to evaluate diagnostic and classification models using Receiver Operating Characteristic curves and the Area Under the Curve.
What Problem Are We Solving?
Imagine a blood test that predicts whether a patient has a disease. It returns a probability score between 0 and 1. But how do you decide the cutoff: at what score do you say "positive"?
Choose too low a cutoff and you flag healthy people as sick (false positives). Choose too high and you miss truly sick patients (false negatives). The ROC curve shows you every possible cutoff at once.
Key Vocabulary
The Confusion Matrix
Every threshold produces a \(2 \times 2\) table of outcomes. The ROC curve is built by computing TPR and FPR from this table at each possible threshold.
How an ROC Curve Is Built
Anatomy of an ROC Curve
What Is AUC?
The Area Under the Curve (AUC) compresses the entire ROC curve into a single number between 0 and 1:
Probabilistic interpretation: AUC equals the probability that a randomly chosen positive case is ranked higher than a randomly chosen negative case by the model.
Sensitivity vs. Specificity
Moving along the ROC curve corresponds to changing the threshold. Every gain in sensitivity comes at a cost in specificity:
| Low Threshold | High Threshold | |
|---|---|---|
| Sensitivity (TPR) | High | Low |
| Specificity (\(1 - \text{FPR}\)) | Low | High |
| False Positives | Many | Few |
| False Negatives | Few | Many |
| Clinical Example | Cancer screening | Confirmatory test |
ROC vs. Precision-Recall
Both curves evaluate classifiers, but they shine in different scenarios.
| ROC Curve | Precision-Recall Curve | |
|---|---|---|
| Y-axis | TPR (Sensitivity) | Precision (PPV) |
| X-axis | FPR | Recall (TPR) |
| Best for | Balanced classes | Imbalanced classes |
| Random baseline | Diagonal line | Horizontal at prevalence |
| Affected by prevalence? | No | Yes |
How to Apply ROC Analysis
Example 1: Small Dataset
A test assigns probabilities to 6 patients. Actual disease status is known. Let us compute two points on the ROC curve.
| Patient | Prob. | Actual |
|---|---|---|
| A | 0.95 | + |
| B | 0.80 | + |
| C | 0.60 | − |
| D | 0.50 | + |
| E | 0.30 | − |
| F | 0.10 | − |
Example 1: More Thresholds
Sweeping the threshold across all distinct probability values produces the full curve:
| Threshold | TPR | FPR |
|---|---|---|
| 1.00 | 0 | 0 |
| 0.95 | \(\frac{1}{3}\) | 0 |
| 0.80 | \(\frac{2}{3}\) | 0 |
| 0.60 | \(\frac{2}{3}\) | \(\frac{1}{3}\) |
| 0.50 | \(\frac{3}{3}\) | \(\frac{1}{3}\) |
| 0.30 | \(\frac{3}{3}\) | \(\frac{2}{3}\) |
| 0.10 | \(\frac{3}{3}\) | \(\frac{3}{3}\) |
Example 2: Comparing Two Models
Choosing the Optimal Threshold
The Youden Index identifies the threshold that maximizes the vertical distance between the ROC curve and the diagonal:
This index identifies the threshold that gives the best performance when sensitivity and specificity are considered equally important. Geometrically, it's the point on the curve furthest vertically from the diagonal line. However, in clinical practice, the chosen threshold may differ from the Youden optimum because:
Common Mistakes
Question 1 of 5
A diagnostic test has an AUC of 0.5. What does this mean?
Question 2 of 5
On an ROC curve, what does the y-axis represent?
Question 3 of 5
A model's ROC curve passes through the point (0.1, 0.85). At that threshold, what is the sensitivity?
Question 4 of 5
When would a Precision-Recall curve be preferred over an ROC curve?
Question 5 of 5
The Youden Index \(J\) is defined as: