Course contentsShow
← Machine Learning and Deep Learning
Lesson 482 of 3,53811. Model Evaluation MetricsFree lesson

Precision-Recall Curve

Plotting precision vs recall across thresholds, especially valuable for imbalanced datasets.

Precision-Recall Curve

What you'll learn: How to visualize the trade-off between precision and recall across different classification thresholds, especially when dealing with imbalanced datasets.

What Is a Precision-Recall Curve?

A Precision-Recall (PR) curve plots precision on the y-axis against recall on the x-axis for every possible classification threshold. Remember that precision measures "of all positive predictions, how many were correct?" while recall measures "of all actual positives, how many did we find?"

As you adjust your classifier's decision threshold (the probability cutoff for predicting positive vs negative), precision and recall move in opposite directions. Lower the threshold, and you'll catch more positives (higher recall) but also get more false positives (lower precision). Raise it, and you become more selective (higher precision) but miss more true positives (lower recall).

Why It Matters for Imbalanced Data

When you have imbalanced classes (say, 95% negative, 5% positive), the ROC curve can be overly optimistic because it includes the true negative rate. The PR curve focuses exclusively on positive class performance, making it more informative when you care primarily about correctly identifying the minority class—like detecting fraud, rare diseases, or spam.

Reading the Curve

  • Top-right corner (high precision AND high recall): ideal performance
  • Trade-off visualization: see exactly how much recall you sacrifice for precision gains
  • Area under the curve (AUC-PR): summarizes overall performance; higher is better

Think of it like a metal detector at the beach: crank up sensitivity (high recall) and you'll find more coins but also lots of bottle caps (low precision). Turn it down (high precision) and you'll mostly find real coins but miss many (low recall).

Key Takeaway: The Precision-Recall curve visualizes the precision-recall trade-off across all thresholds and is especially valuable for imbalanced datasets where the positive class matters most.