nested_cv: Nested K-fold Cross Validation for Binary Classification

Description Usage Arguments Details Value Examples

Description

A wrapper function that implements nested K-fold cross validation for a chosen algorithm with binary data.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
nested_cv(y, X, type, K = c(10, 10), control = list(),
  set_control = list(), progress = T)

is.nested_cv(x)

## S3 method for class 'nested_cv'
levels(x)

## S3 method for class 'nested_cv'
dimnames(x)

## S3 method for class 'nested_cv'
coef(x, int = T)

## S3 method for class 'nested_cv'
print(x, digits = 2, metric = "AUC")

## S3 method for class 'nested_cv'
summary(x, metric = "AUC")

## S3 method for class 'nested_cv'
features(x, cutoff = 0.95)

Arguments

y

A factor with two levels.

X

A matrix of predictors with the number of rows equal to the length of y.

type

The type of fitting algorithm to use. Options include glm and glmnet.

K

A vector indicating the number of folds to use for the outer and inner iterations.

control

List of additional settings for the estimation algorithm for the inner folds.

set_control

A function to specify how to set the control option for the outer folds based on the results of the inner folds.

progress

Logical; if TRUE, tracks the progress of the algoritm through both the inner and outer folds.

Details

The method summary returns a list with the coefficients and their significance for the outer folds and the inner folds per each outer fold, respectively.

Value

An R object of class 'nested_cv'.

Examples

1
2
3
4
5
6
# Simulate data
sim = bc_simulate( 500, 8, 4 )
# Conduct nested 10-fold CV
cv_glm = nested_cv( sim$y, sim$X, type = 'glm' )
# Can be slow
cv_glmnet = nested_cv( sim$y, sim$X, type = 'glmnet' )

rettopnivek/binclass documentation built on May 13, 2019, 4:46 p.m.