袋外估计用于估计错误,我认为您不能使用该包切换到 CV。 CV是否比这更好由您决定。在他们的readme 中,他们链接到publication,并在其第 3.5 节下写道:
袋外预测用于评估,这很重要
比其他使用评估策略的软件包更快,例如
交叉验证
如果要使用交叉验证或重复交叉验证,则必须使用caret,例如:
library(caret)
mdl = train(Species ~ .,data=iris,method="ranger",trControl=trainControl(method="repeatedcv",repeats=2),
tuneGrid = expand.grid(mtry=2:3,min.node.size = 1:2,splitrule="gini"))
Random Forest
150 samples
4 predictor
3 classes: 'setosa', 'versicolor', 'virginica'
No pre-processing
Resampling: Cross-Validated (10 fold, repeated 2 times)
Summary of sample sizes: 135, 135, 135, 135, 135, 135, ...
Resampling results across tuning parameters:
mtry min.node.size Accuracy Kappa
2 1 0.96 0.94
2 2 0.96 0.94
3 1 0.96 0.94
3 2 0.96 0.94
Tuning parameter 'splitrule' was held constant at a value of gini
Accuracy was used to select the optimal model using the largest value.
The final values used for the model were mtry = 2, splitrule = gini
and min.node.size = 1.
您可以调整的参数会有所不同。我认为mlr 也允许您执行cross-validation,但同样的限制也适用。