回复如何创建自定义尺寸的折叠?
rsmp. How to create folds with custom size?
这里我创建了3个大小相同的折叠
task <- tsk("iris")
folds <- rsmp("cv", folds = 3)$instantiate(task)
是否可以创建 n 个折叠,每个折叠大小不同?
您可以使用 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)
这里我创建了3个大小相同的折叠
task <- tsk("iris")
folds <- rsmp("cv", folds = 3)$instantiate(task)
是否可以创建 n 个折叠,每个折叠大小不同?
您可以使用 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)