主要问题:
阅读文档和谷歌搜索后,我仍然不清楚建议在哪些情况下预定义重采样指数是明智的,比如:
resamples <- createResample(classVector_training, times = 500, list=TRUE)
或预定义种子,例如:
seeds <- vector(mode = "list", length = 501) #length is = (n_repeats*nresampling)+1
for(i in 1:501) seeds[[i]]<- sample.int(n=1000, 1)
我的计划是使用doParallel包并行处理来训练多个可重复的模型。由于已经设置了种子,预定义重新采样是否不必要?我需要像上面那样预定义种子而不是在trainControl对象中设置seeds=NULL,因为我打算使用并行处理吗?有没有理由预定义索引和种子,因为我至少通过搜索谷歌看到过一次?什么情况下需要使用indexOut?
附带问题:
到目前为止,我已经成功地运行了RF的train。
rfControl <- trainControl(method="oob", number = 500, p = 0.7, returnData=TRUE, returnResamp = "all", savePredictions=TRUE, classProbs = TRUE, summaryFunction = twoClassSummary, allowParallel=TRUE)
mtryGrid <- expand.grid(mtry = 9480^0.5) #set mtry parameter to the square root of the number of variables
rfTrain <- train(x = training, y = classVector_training, method = "rf", trControl = rfControl, tuneGrid = mtryGrid)
但是当我尝试使用方法为“baruta”的train()运行时:
borutaControl <- trainControl(method="bootstrap", number = 500, p = 0.7, returnData=TRUE, returnResamp = "all", savePredictions=TRUE, classProbs = TRUE, summaryFunction = twoClassSummary, allowParallel=TRUE)
borutaTrain <- train(x = training, y = classVector_training, method = "Boruta", trControl = borutaControl, tuneGrid = mtryGrid)
我最终得到了以下错误:
Error in names(trControl$indexOut) <- prettySeq(trControl$indexOut) : 'names' attribute [1] must be the same length as the vector [0]
有人知道为什么吗?
R-caret
。 - topepofloor(9480^0.5)
得到一个整数。 - topepo