compute_auc: Compute Area Under the Receiver Operating Characteristic...

Description Usage Arguments Value See Also Examples

View source: R/roc_auc_utils.R

Description

Compute Area Under the Receiver Operating Characteristic Curve (AUC)

Usage

1
compute_auc(preds, labs)

Arguments

preds

vector of predicted probabilities (numeric)

labs

vector of true class labels (numeric)

Value

value of Area Under the Receiver Operating Characteristic Curve (AUC) (numeric)

See Also

performance

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
# First, we load data, train a model, and generate predictions to evaluate.
data("recidivism")
recidivism$returned = as.factor(recidivism$Return.Status != "Not Returned")
in_train = caret::createDataPartition(recidivism$returned, 
    p = 0.75, list = FALSE)
traindata = recidivism[in_train,c("Release.Year", "County.of.Indictment", 
    "Gender", "Age.at.Release", "returned")]
testdata = recidivism[-in_train,c("Release.Year", "County.of.Indictment", 
    "Gender", "Age.at.Release", "returned")]
lr = glm(returned ~ ., data=traindata, family="binomial")
testdata$pred = predict(lr, testdata, type = "response")

# Now, we apply compute_auc() to the labels and predictions:
compute_auc(testdata$pred, testdata$returned)

jpgard/abroca documentation built on May 25, 2019, 11:31 p.m.