interpolate_roc_fun: Use interpolation to make approximate the Receiver Operating...

Description Usage Arguments Value See Also Examples

View source: R/roc_auc_utils.R

Description

Use interpolation to make approximate the Receiver Operating Characteristic (ROC) curve along n_grid equally-spaced values.

Usage

1
interpolate_roc_fun(perf_in, n_grid = 10000)

Arguments

perf_in

ROCR::performance object computed via compute_roc

n_grid

number of approximation points to use (default value of 10000 more than adequate for most applications) (numeric)

Value

returns a list with components x and y, containing n coordinates which interpolate the given data points according to the method (and rule) desired.

See Also

approx

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# 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_roc() to the labels and predictions,
# which generates a ROCR::performance object:
roc <- compute_roc(testdata$pred, testdata$returned)

# Interpolate_roc_fun is applied to this object:
roc_approx <- interpolate_roc_fun(roc)

# You can also increase the quality of the approximation.
# Increasing the approximation rarely makes a substantial difference,
# but is available as a convenience for massive datasets or when
# precision is critical.
roc_approx_finegrain <- interpolate_roc_fun(roc, n_grid = 1000000)

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