Runs a resampling (possibly in parallel).

resample(task, learner, resampling, ctrl = list())

Arguments

task

(Task): Object of type Task.

learner

(Learner): Object of type Learner.

resampling

(Resampling): Object of type Resampling.

ctrl

(named list(), e.g. as returned by mlr_control()): Object to control various parts of the execution. See mlr_control().

Value

ResampleResult.

Examples

task = mlr_tasks$get("iris") learner = mlr_learners$get("classif.rpart") resampling = mlr_resamplings$get("cv") # explicitly instantiate the resampling for this task for reproduciblity set.seed(123) resampling$instantiate(task) rr = resample(task, learner, resampling) print(rr, digits = 2)
#> <ResampleResult> of learner 'iris' on task 'classif.rpart' with 10 iterations #> Measure Min. 1st Qu. Median Mean 3rd Qu. Max. Sd #> classif.mmce 0 0.067 0.067 0.073 0.12 0.13 0.049
rr$aggregated
#> classif.mmce #> 0.07333333
rr$performance("classif.mmce")
#> [1] 0.00000000 0.13333333 0.06666667 0.06666667 0.06666667 0.13333333 #> [7] 0.06666667 0.06666667 0.13333333 0.00000000
# Repeat resampling with featureless learner and combine # the ResampleResults into a BenchmarkResult learner = mlr_learners$get("classif.featureless") rr.featureless = resample(task, learner, resampling) bmr = rr$combine(rr.featureless) bmr$aggregated(objects = FALSE)
#> hash resampling_id task_id learner_id classif.mmce #> 1: fc917ec4badc43d8 cv iris classif.rpart 0.07333333 #> 2: a6523dd230cc46d1 cv iris classif.featureless 0.80666667