Learn R Programming

healthcareai (version 1.2.4)

generateAUC: Generate ROC or PR curve for a dataset.

Description

Generates ROC curve and AUC for Sensitivity/Specificity or Precision/Recall.

Usage

generateAUC(predictions, labels, aucType = "SS", plotFlg = FALSE,
  allCutoffsFlg = FALSE)

Arguments

predictions

A vector of predictions from a machine learning model.

labels

A vector of the true labels. Must be the same length as predictions.

aucType

A string. Indicates AUC_ROC or AU_PR and can be "SS" or "PR". Defaults to SS.

plotFlg

Binary value controlling plots. Defaults to FALSE (no).

allCutoffsFlg

Binary value controlling list of all thresholds. Defaults to FALSE (no).

Value

AUC: A number between 0 and 1. Integral AUC of chosen plot type.

IdealCutoffs: Array of cutoff and associated TPR/FPR or pre/rec.

Performance: ROCR performance class containing all ROC information.

References

http://healthcareai-r.readthedocs.io

See Also

healthcareai

Examples

Run this code
# NOT RUN {
# generate data
# example probablities
df <- data.frame(a = rep( seq(0,1,by=0.1), times=9))
# example ground truth values
df[,'b'] <- (runif(99,0,1)*df[,'a']) > 0.5

# prepare vectors
pred <- df[,'a']
labels <- df[,'b']

# generate the AUC
auc = generateAUC(predictions = pred, 
                  labels = labels,
                  aucType = 'SS',
                  plotFlg = TRUE,
                  allCutoffsFlg = TRUE)
# }

Run the code above in your browser using DataLab