This is not so much a problem, as it is me making sure I understand what's happening with my Random Forest algorithm.
Below, I've set a few parameters. Am I right in thinking that this is the stages:
Model is being run 10 times due to 10 Fold Cross Validation, whereby data is being split into 10 folds (9 used for training, 1 for validation - repeated k times, each time with a different group used for validation).
For each model, 500 individual decision trees (
ntree) are being generated to create the Random Forest.
tuneLengthis 5, steps 1 and 2 are repeated 5 times - each time with
mtrybeing set to a different number.
Also, I ran this on my training data.
Is it normal practice to next pass the separate test data into the model to check how well it's able to predict the target variable. Then if satisfied with the outcome, re-create the model with all of the data?
I could really use some clarification here, as I think I may be getting this all wrong. The results of the below model tell me what the optimal
mtry is (i.e. 2). So I'm unsure if I should then be creating an entirely new model, removing the
trControl parameter, and manually adding in
mtry as 2 if possible.
set.seed(1) rf_test <- train(mortality ~., data = rf_train, method = "rf", ntree = 500, trControl = trainControl(method = "CV", number = 10), tuneLength = 5) print(rf_test)