kfold_cv: K-fold Cross Validation for Binary Classification

Description Usage Arguments Details Value Examples

Description

A wrapper function that implements 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
23
24
kfold_cv(y, X, type, K = 10, control = list(), progress = T)

is.kfold_cv(x)

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

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

## S3 method for class 'kfold_cv'
max(x, train = F, metric = "AUC", na.rm = FALSE)

## S3 method for class 'kfold_cv'
features(x, metric = "AUC")

## S3 method for class 'kfold_cv'
coef(x, int = F, sig = T, metric = "AUC")

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

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

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

The number of folds to use.

control

An optional list of estimation parameters for the chosen algorithm.

progress

Logical; If TRUE prints a progress bar tracking which folds have finished estimation.

Details

The method max can be used to extract the label for the fold that produced the best value for a specified metric with the test sample. The method features extracts the labels for the independent variables associated with the best-performing fold. The method summary reports the coefficients and denotes which were statistically significant across all folds.

Value

An R object of class 'kfold_cv'.

Examples

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

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