mlr3 中的留一法交叉验证

ds_*_*col 3 cross-validation mlr3

我喜欢在 mlr3 中使用留一法交叉验证(作为管道的一部分)。

我可以指定折叠数(=实例数),例如通过

resampling = rsmp("cv", folds=task$nrow)
Run Code Online (Sandbox Code Playgroud)

但这明确指的是可能无法在管道中工作的“任务”。

我怎样才能在这里继续?

小智 6

有一个特定的“留一法”Resampling对象,名为"loo"。它可以像任何Resampling对象一样使用,例如:

rs <- rsmp("loo")
rr <- resample(tsk("iris"), lrn("classif.rpart"), resampling = rs)
rr$aggregate()
#> classif.ce
#> 0.06666667
Run Code Online (Sandbox Code Playgroud)

它直接从Task使用中确定迭代次数,并且没有配置参数(即有一个空的$param_set)。