What the curves measure
A classifier often produces a score, such as a probability. Choosing a threshold turns those scores into positive or negative predictions. Each threshold gives a confusion matrix and a point on each curve.
True positive rate (recall) = TP / (TP + FN)
False positive rate = FP / (FP + TN)
Precision = TP / (TP + FP)
The ROC curve plots true positive rate against false positive rate. The precision–recall curve plots precision against recall. ROC AUC summarises ranking across thresholds; average precision summarises precision as recall increases. Neither metric chooses a deployment threshold or checks whether predicted probabilities are calibrated.
A rare-class example
Suppose a test set contains 100 positive cases and 9,900 negatives. At one threshold, a model catches 90 positives (recall 0.90) and incorrectly flags 5% of negatives. That is 495 false positives, so precision is:
90 / (90 + 495) ≈ 0.154
The ROC point is (FPR 0.05, TPR 0.90). If the same rates held in a balanced set with 100 negatives, there would be 5 false positives and precision would be 90 / 95 ≈ 0.947. The true-positive and false-positive rates are unchanged, but the number of false alarms and the precision differ because prevalence changed.
Change prevalence in the visualiser
- Set Fraction of rows that are positive near 0.50, then note the ROC and precision–recall curves.
- Lower it toward 0.01. The ROC baseline remains 0.5 for random ranking, while the no-skill precision–recall baseline follows the positive-class prevalence. With rare positives, small false-positive rates can still produce many false alarms.
The exact curve shape depends on the scores; the key distinction is how the axes and baselines respond to class balance.
Which one should you use?
| Question | Useful view | What to keep in mind |
|---|
| How well does the model rank positives above negatives overall? | ROC AUC | It is prevalence-insensitive when the class-conditional score distributions stay fixed, but it does not show the volume of alerts by itself. |
| How many flagged cases are correct, and how many positives are found? | Precision–recall | Its baseline changes with prevalence, so compare scores against that baseline and use the intended deployment prevalence. |
| What threshold should run in production? | Neither curve alone | Choose on validation data using the costs or capacity limits of false alarms and misses. |
Precision–recall is often more revealing for rare-positive tasks such as fraud review or defect detection. ROC remains useful for ranking and for seeing the false-positive rate directly. Read both in the context of the task, and use threshold tuning to choose an operating point. The scikit-learn evaluation guide documents these metrics; Davis and Goadrich discuss the relationship between ROC and precision–recall spaces in their ICML paper.