'How to tune mtry and number of trees simultaneously for a Random Forest Regression?

I am trying to tune parameters for a Random Forest using caret and method ranger. I have seen codes for tuning mtry using tuneGrid. And then using the resulted mtry to run loops and tune the number of trees (num.tree). However, I would like to know if it is possible to tune them both at the same time, to find out the best model between all possible combinations. I do not want to keep one argument constant and tune the other one, but both at the same time. Is there any way?



Solution 1:[1]

You cannot tune ntree as part of a tuneGrid for Random Forest in caret; only mtry, splitrule and min.node.size - see the tuning parameters for each model type here: https://topepo.github.io/caret/available-models.html

ntree can only be specified in train.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 rw2