resample: Resample data

View source: R/resample.R

resampleR Documentation

Resample data

Description

Create resamples of your data, e.g. for model building or validation. "KFold" creates stratified folds, , "StratSub" creates stratified subsamples, "Bootstrap" gives the standard bootstrap, i.e. random sampling with replacement, while "StratBoot" uses StratSub and then randomly duplicates some of the training cases to reach original length of input (default) or length defined by target_length.

Usage

resample(x, parameters = setup_Resampler(), verbosity = 1L)

Arguments

x

Vector or data.frame: Usually the outcome; NROW(x) defines the sample size.

parameters

Resampler object created by setup_Resampler.

verbosity

Integer: Verbosity level.

Details

Note that option 'KFold' may result in resamples of slightly different length. Avoid all operations which rely on equal-length vectors. For example, you can't place resamples in a data.frame, but must use a list instead.

Value

Resampler object.

Author(s)

EDG

Examples

## Not run: 
y <- rnorm(200)
# 10-fold (stratified)
res <- resample(y, 10, "KFold")
# 25 stratified subsamples
res <- resample(y, 25, "StratSub")
# 100 stratified bootstraps
res <- resample(y, 100, "StratBoot")

## End(Not run)

egenn/rtemis documentation built on June 14, 2025, 11:54 p.m.