Reputation: 139
I like to use Leave-One-Out Cross-Validation in mlr3 (as part of a pipeline).
I could specify the number of folds (=number of instances) e.g. via
resampling = rsmp("cv", folds=task$nrow)
But this refers explicitly to "task" which may not work in the pipeline.
How can I proceed here?
Upvotes: 3
Views: 198
Reputation: 672
There is a specific "leave-one-out" Resampling
object, named "loo"
. It can be used like any Resampling
object, for example:
rs <- rsmp("loo")
rr <- resample(tsk("iris"), lrn("classif.rpart"), resampling = rs)
rr$aggregate()
#> classif.ce
#> 0.06666667
It determines the number of iterations directly from the Task
being used, and has no configuration parameters (i.e. has an empty $param_set
).
Upvotes: 6