From below code, I am getting optimal number of mtry. What is this mtry ? and How should I find the optimal number of tree that to be assigned to Random forest algorithm so that it will give High accuracy.

Any comment will be highly appreciated ! Thanks in Advance.

classifier = train(form = Survived ~ ., data = training_set_scaled, method = 'rf')

1 Answer 1


mtry is the parameter indicating how many of the features are checked in each split decision. http://topepo.github.io/caret/train-models-by-tag.html#random-forest , see method 'rf'

In Random Forest, usually more trees give more stable results, and overfitting due to number of trees is rare. Moreover, since the trees are built independently, you could just fit many trees then take subsets to get smaller models. But, see e.g. hyperparameter tuning in mlr for how to perform grid, random, Bayesian, and other hyperparameter searches, or grid in caret or random in caret.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.