Skip to contents

A generic function that applies a cross-validation scheme to split the data into training and testing sets. It is used along with cross-validation control objects and S3 implementation functions to perform the cross-validation process.

Usage

crossval_samples(obj, data, y, ...)

Arguments

obj

A cross-validation control object.

data

A data frame containing the predictor variables.

y

A vector containing the response variable.

...

Extra arguments passed to the specific cross-validation methods.

Value

A tibble containing the training and testing sets for each fold, as well as the response variables for both sets.

See also

crossval_samples.sequential_blocked_cross_validation, crossval_samples.kfold_cross_validation, crossval_samples.blocked_cross_validation, crossval_samples.bootstrap_blocked_cross_validation, crossval_samples.custom_cross_validation, crossval_samples.twofold_blocked_cross_validation

Examples

# Example with k-fold cross-validation
cval <- kfold_cross_validation(len=100, nfolds=10)
samples <- crossval_samples(cval, data=as.data.frame(matrix(rnorm(100*10), 100, 10)), y=rep(letters[1:5],20))
stopifnot(nrow(samples) == 10)