I searched around CV and the caret documentation but couldn't find an answer to this. I'm using caret
in R to tune some random forests for classification trained using ranger
. I've made a tuning grid that varies the number of variables sampled, mtry
, and the minimum node size, min.node.size
in this dataset. I defined the grid as follows:
mtry <- floor(sqrt(ncol(train_x)))
grid_rf <- expand.grid(
.mtry = c(mtry/4, mtry/2, mtry, mtry*2, mtry*4),
.splitrule = "gini",
.min.node.size = c(1, 10, 20)
)
So this grid should yield 15 models. Next, I set the trainControl function to use out of bag error, trainControl(method = "oob")
. There are no repeats, because the method isn't repeated cross-validation. So I would only expect 15 models to be trained and the model with lowest OOB error to be chosen. However, looking at the "Growing trees.. Progress: X%"
progress message that ranger prints, I can see that right now it's starting to train the 16th random forest instead of stopping, because it has already hit 100% 15 times and is starting to train a new forest.
Did I misunderstand the trainControl() function? How many models is it supposed to train?
Thanks for reading my post!