我希望使用caret包并行运行随机森林,并像Fully reproducible parallel models using caret中设置种子以获取可再现的结果。但是,我不理解从caret帮助文档中提取的以下代码第9行的作用:为什么我们要采样22个整数(加上第12行和23行的最后一个模型),来评估12个参数k的12个值? 请注意,我希望运行5倍交叉验证来评估RF参数“mtry”的584个值。非常感谢您的帮助。谢谢。
## Not run:
## Do 5 repeats of 10-Fold CV for the iris data. We will fit
## a KNN model that evaluates 12 values of k and set the seed
## at each iteration.
set.seed(123)
seeds <- vector(mode = "list", length = 51)
for(i in 1:50) seeds[[i]] <- sample.int(1000, 22) # Why 22?
## For the last model:
seeds[[51]] <- sample.int(1000, 1)
ctrl <- trainControl(method = "repeatedcv",
repeats = 5,
seeds = seeds)