Reputation: 421
How to obtain AUC (area under curve) of a Precision Recall Curve by using package ROCR..?
library(ROCR)
data(ROCR.simple)
pred <- prediction( ROCR.simple$predictions, ROCR.simple$labels)
perf <- performance(pred,"tpr","fpr")
plot(perf)
## precision/recall curve (x-axis: recall, y-axis: precision)
perf1 <- performance(pred, "prec", "rec")
plot(perf1)
Upvotes: 5
Views: 5737
Reputation: 11
It looks like there are 2 measures for ROCR. auc and aucpr. This worked for me
For ROC
perfauc <- performance(pred, "auc")
For PR
perf1auc <- performance(pred, "aucpr")
Upvotes: 1
Reputation: 2469
ROCR can calculate AUC directly:
perf <- performance(pred, "auc")
Get AUC
[email protected][[1]]
Upvotes: -1
Reputation: 723
You can first get the precision and recall values
x <- [email protected][[1]] # Recall values
y <- [email protected][[1]] # Precision values
and then calculate Area under the curve using any of the methods from calculate area under the curve
Upvotes: 2