Precision-Recall Curve for Imbalanced Data
What you'll learn: Why Precision-Recall curves are more informative than ROC curves when dealing with datasets where the positive class is rare.
The Problem with ROC Curves on Imbalanced Data
Remember ROC curves plot True Positive Rate (recall) against False Positive Rate. Here's the issue: when your positive class is rare (say, fraud detection where 99% of transactions are legitimate), the False Positive Rate can be misleadingly optimistic.
Why? False Positive Rate = FP / (FP + TN). With thousands of true negatives, even many false positives result in a tiny FPR, making your ROC curve look great when your model might actually be producing tons of false alarms.
Enter the Precision-Recall Curve
The Precision-Recall (PR) curve plots Precision against Recall at different classification thresholds. Crucially, it doesn't use True Negatives in its calculations:
- Precision = TP / (TP + FP) — focuses on predicted positives
- Recall = TP / (TP + FN) — focuses on actual positives
Both metrics concentrate entirely on the positive class, making PR curves much more sensitive to how well your model handles the minority class.
When to Use PR Curves
Use PR curves when:
- Your positive class is rare (fraud, disease diagnosis, anomaly detection)
- You care more about correctly identifying positives than correctly rejecting negatives
- You want an honest assessment without the "inflation" from many true negatives
Analogy: Imagine finding needles (positives) in a haystack (negatives). ROC says "look how well we avoided the hay!" while PR asks "how many needles did we actually find, and how much hay came with them?"
Key Takeaway: For imbalanced datasets where the positive class is rare, Precision-Recall curves provide a more realistic and informative view of model performance than ROC curves, which can appear overly optimistic due to the abundance of true negatives.