Resamplings split the observations multiple times into two sets: training and test. The former is used to fit the model, the latter is used to evaluate the predictions. The Resampling objects provide an abstraction for this procedure while respecting stratification as well as grouping/blocking if this is required by the Task.

If only a single split is required (i.e., a holdout split), the partition() function provides a single split into training and test set.

Example Usage

Fit a Random Forest on the Wisconsin Breast Cancer Data Set using a 3-fold cross validation.

Loading required package: mlr3
# retrieve the task
task = tsk("breast_cancer")

# retrieve a learner
learner = lrn("classif.ranger")

# retrieve resampling strategy
resampling = rsmp("cv", folds = 3)

# perform resampling
rr = resample(task, learner, resampling)
INFO  [20:31:36.176] [mlr3] Applying learner 'classif.ranger' on task 'breast_cancer' (iter 1/3)
INFO  [20:31:36.724] [mlr3] Applying learner 'classif.ranger' on task 'breast_cancer' (iter 2/3)
INFO  [20:31:36.792] [mlr3] Applying learner 'classif.ranger' on task 'breast_cancer' (iter 3/3)
<ResampleResult> with 3 resampling iterations
       task_id     learner_id resampling_id iteration warnings errors
 breast_cancer classif.ranger            cv         1        0      0
 breast_cancer classif.ranger            cv         2        0      0
 breast_cancer classif.ranger            cv         3        0      0