cvAUC {cvAUC}R Documentation

Cross-validated Area Under the ROC Curve (AUC)


This function calculates cross-validated area under the ROC curve (AUC) esimates. For each fold, the empirical AUC is calculated, and the mean of the fold AUCs is the cross-validated AUC estimate. The area under the ROC curve is equal to the probability that the classifier will score a randomly drawn positive sample higher than a randomly drawn negative sample. This function is a simple wrapper for the AUC functionality inside the ROCR package.


cvAUC(predictions, labels, label.ordering = NULL, folds = NULL)



A vector, matrix, list, or data frame containing the predictions.


A vector, matrix, list, or data frame containing the true class labels. Must have the same dimensions as predictions.


The default ordering of the classes can be changed by supplying a vector containing the negative and the positive class label (negative label first, positive label second).


If specified, this must be a vector of fold ids equal in length to predictions and labels, or a list of length V (for V-fold cross-validation) of vectors of indexes for the observations contained in each fold. The folds argument must only be specified if the predictions and labels arguments are vectors.


If predictions and labels are provided as vectors and folds is NULL, then this function will return AUC (not cross-validated). See the documentation for the prediction function in the ROCR package for details on the predictions, labels and label.ordering arguments.



An object of class 'performance' from the ROCR package. Can be used to plot the ROC curve.


A vector containing the AUC estimate for each fold.


Cross-validated area under the curve.


Erin LeDell


Tobias Sing, Oliver Sander, Niko Beerenwinkel, and Thomas Lengauer. ROCR: Visualizing classifier performance in R. Bioinformatics, 21(20):3940-3941, 2005.

See Also

prediction, performance, ci.cvAUC, ci.pooled.cvAUC


# Example of how to get CV AUC and plot the curve.
library(ROCR)  #load example data

out <- cvAUC(ROCR.xval$predictions, ROCR.xval$labels)

#Plot fold AUCs
plot(out$perf, col = "grey82", lty = 3, main = "10-fold CV AUC")

#Plot CV AUC
plot(out$perf, col ="red", avg = "vertical", add = TRUE)

# See the ci.cvAUC documentation for an example 
# of how to use the `folds` argument.

[Package cvAUC version 1.1.4 Index]