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)
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
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")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With