# Area under the ROC curve or area under the PR curve for imbalanced data?

I have some doubts about which performance measure to use, area under the ROC curve (TPR as a function of FPR) or area under the precision-recall curve (precision as a function of recall).

My data is imbalanced, i.e., the number of negative instances is much larger than positive instances.

I am using the output prediction of weka, a sample is:

inst#,actual,predicted,prediction
1,2:0,2:0,0.873
2,2:0,2:0,0.972
3,2:0,2:0,0.97
4,2:0,2:0,0.97
5,2:0,2:0,0.97
6,2:0,2:0,0.896
7,2:0,2:0,0.973


And I am using pROC and ROCR r libraries.

• You forgot to mention what you want to achieve with any of these curves. – Marc Claesen Mar 20 '14 at 21:25
• Note: it seems you want to choose between ROC curves (TPR as a function of FPR over the entire operating range) and PR curves (precision versus recall over the entire operating range). Terminology like "AUC-ROC of precision and recall" is very misleading, so I've edited this. Please revert it if I misunderstood. – Marc Claesen Mar 20 '14 at 21:37

## 3 Answers

The question is quite vague so I am going to assume you want to choose an appropriate performance measure to compare different models. For a good overview of the key differences between ROC and PR curves, you can refer to the following paper: The Relationship Between Precision-Recall and ROC Curves by Davis and Goadrich.

To quote Davis and Goadrich:

However, when dealing with highly skewed datasets, Precision-Recall (PR) curves give a more informative picture of an algorithm's performance.

ROC curves plot FPR vs TPR. To be more explicit: $$FPR = \frac{FP}{FP+TN}, \quad TPR=\frac{TP}{TP+FN}.$$ PR curves plot precision versus recall (FPR), or more explicitly: $$recall = \frac{TP}{TP+FN} = TPR,\quad precision = \frac{TP}{TP+FP}$$

Precision is directly influenced by class (im)balance since $FP$ is affected, whereas TPR only depends on positives. This is why ROC curves do not capture such effects.

Precision-recall curves are better to highlight differences between models for highly imbalanced data sets. If you want to compare different models in imbalanced settings, area under the PR curve will likely exhibit larger differences than area under the ROC curve.

That said, ROC curves are much more common (even if they are less suited). Depending on your audience, ROC curves may be the lingua franca so using those is probably the safer choice. If one model completely dominates another in PR space (e.g. always have higher precision over the entire recall range), it will also dominate in ROC space. If the curves cross in either space they will also cross in the other. In other words, the main conclusions will be similar no matter which curve you use.

Shameless advertisement. As an additional example, you could have a look at one of my papers in which I report both ROC and PR curves in an imbalanced setting. Figure 3 contains ROC and PR curves for identical models, clearly showing the difference between the two. To compare area under the PR versus area under ROC you can compare tables 1-2 (AUPR) and tables 3-4 (AUROC) where you can see that AUPR shows much larger differences between individual models than AUROC. This emphasizes the suitability of PR curves once more.

• Thanks for the explanation. The question now, why PR curves are more informative for imbalanced data? For me, ROC should be more informative because it considers both TPR and FPR. – M.M Mar 21 '14 at 0:59
• In addition, these two articles make me more confused! onlinelibrary.wiley.com/doi/10.1111/j.1466-8238.2007.00358.x/… riceanalytics.com/db3/00232/riceanalytics.com/_download/… – M.M Mar 21 '14 at 1:02
• @M.A edited my answer to clarify. – Marc Claesen Mar 21 '14 at 7:37
• I think there is a mixup in the equation for recall between TPR and FPR, no? – Simon Thordal Nov 7 '16 at 15:40
• You're right, it should be: recall = ... = TPR, not FPR. @Marc Claesen, I think only you can change that, because when I try to do it, I'm informed that: "Edits should have at least 6 characters", so it's impossible to correct small typos, such as this one. – ponadto Dec 9 '16 at 6:37

ROC curves plot TPR on the y-axis and FPR on the x-axis, but it depends on what you want to portray. Unless there is some reason to plot it differently in your area of study, TPR/FPR ROC curves are the standard for showing operating tradeoffs and I believe they would be most well received.

Precision and Recall alone can be misleading because it does not account for true negatives.

I consider the largest difference in ROC and PR AUC the fact the ROC is determining how well your model can "calculate" the positive class AND the negative class where as the PR AUC is really only looking at your positive class. So in a balanced class situation and where you care about both negative and positive classes, the ROC AUC metric works great. When you have an imbalanced situation, it is preferred to use the PR AUC, but keep in mind it is only determining how well your model can "calculate" the positive class!