Skip to contents

Folds follow numpy's array_split: the first n %% K folds get one extra member. All indices are 0-based.

Usage

morie_geron_kfold_cv(n, K, shuffle = FALSE, seed = 0)

Arguments

n

Number of instances (at least 2).

K

Folds in [2, n].

shuffle

Permute with the LCG Fisher-Yates first.

seed

LCG seed.

Value

List with splits (each train / val), val_folds, fold_sizes, each_used_once, train_size.

Examples

morie_geron_kfold_cv(n = 5L, K = 5L)
#> $splits
#> $splits[[1]]
#> $splits[[1]]$train
#> [1] 1 2 3 4
#> 
#> $splits[[1]]$val
#> [1] 0
#> 
#> 
#> $splits[[2]]
#> $splits[[2]]$train
#> [1] 0 2 3 4
#> 
#> $splits[[2]]$val
#> [1] 1
#> 
#> 
#> $splits[[3]]
#> $splits[[3]]$train
#> [1] 0 1 3 4
#> 
#> $splits[[3]]$val
#> [1] 2
#> 
#> 
#> $splits[[4]]
#> $splits[[4]]$train
#> [1] 0 1 2 4
#> 
#> $splits[[4]]$val
#> [1] 3
#> 
#> 
#> $splits[[5]]
#> $splits[[5]]$train
#> [1] 0 1 2 3
#> 
#> $splits[[5]]$val
#> [1] 4
#> 
#> 
#> 
#> $val_folds
#> $val_folds[[1]]
#> [1] 0
#> 
#> $val_folds[[2]]
#> [1] 1
#> 
#> $val_folds[[3]]
#> [1] 2
#> 
#> $val_folds[[4]]
#> [1] 3
#> 
#> $val_folds[[5]]
#> [1] 4
#> 
#> 
#> $fold_sizes
#> [1] 1 1 1 1 1
#> 
#> $each_used_once
#> [1] TRUE
#> 
#> $train_size
#> [1] 4 4 4 4 4
#> 
#> $K
#> [1] 5
#> 
#> $seed
#> [1] 0
#> 
#> $estimate
#> $estimate[[1]]
#> $estimate[[1]]$train
#> [1] 1 2 3 4
#> 
#> $estimate[[1]]$val
#> [1] 0
#> 
#> 
#> $estimate[[2]]
#> $estimate[[2]]$train
#> [1] 0 2 3 4
#> 
#> $estimate[[2]]$val
#> [1] 1
#> 
#> 
#> $estimate[[3]]
#> $estimate[[3]]$train
#> [1] 0 1 3 4
#> 
#> $estimate[[3]]$val
#> [1] 2
#> 
#> 
#> $estimate[[4]]
#> $estimate[[4]]$train
#> [1] 0 1 2 4
#> 
#> $estimate[[4]]$val
#> [1] 3
#> 
#> 
#> $estimate[[5]]
#> $estimate[[5]]$train
#> [1] 0 1 2 3
#> 
#> $estimate[[5]]$val
#> [1] 4
#> 
#> 
#> 
#> $n
#> [1] 5
#>