Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AUC of a Precision Recall Curve by using package ROCR

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)
like image 462
Newbie Avatar asked Nov 09 '22 09:11

Newbie


2 Answers

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

like image 95
user2715182 Avatar answered Nov 15 '22 06:11

user2715182


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")
like image 33
user72036 Avatar answered Nov 15 '22 06:11

user72036