I have binary labels and predicted probabilities. Which R function should I use to calculate the ROC_ROC?

+2 votes

Best answer

You can use the **auc()** function of the pROC library to calculate the AUC ROC. This function computes the numeric value of the area under the ROC curve (AUC) with the trapezoidal rule.

In the following example, I have generated random probabilities "preds" and labels "y" to compute AUC.

library(pROC)

preds <- runif(n=20)

y <- rbinom(length(preds), prob = preds, size = 1)auc(y, preds)