2

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?

1 Answer 1

4

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)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.