Here I create 3 folds with the same size
task <- tsk("iris")
folds <- rsmp("cv", folds = 3)$instantiate(task)
Is is possible to create n folds, each with a different size?
You can use ResamplingCustomCV
.
library(mlr3)
# Create a task with 10 observations
task = tsk("penguins")
task$filter(1:10)
# Instantiate Resampling
custom_cv = rsmp("custom_cv")
f = factor(c("a", "a", "b", "b", "b", "c", "c", "c", "d", "d"))
custom_cv$instantiate(task, f = f)
custom_cv$iters # 4 folds
# Individual sets
custom_cv$train_set(1)
custom_cv$test_set(1)