0
$\begingroup$

I have trained model for classification task in R using randomForest - "RF_Model"

RF_Model <- randomForest(measure ~., data = dat), mtry=3, importance=TRUE,ntree=500)
print(RF_Model)

returns:

Call: randomForest(formula = measure ~ ., data = dat) Type of random forest: classification Number of trees: 500 No. of variables tried at each split: 3

Each object, which uses in that model, has 15 attributes. In my understanding (the basic knowledge I have got from here): mtry = number of random variables used in each tree. So, I thought, that for each sample decision tree (from those 500 trees in the forest) will be used only 3 different attributes from 15.

But when I tried to check that - I found that all the 15 attributes are used for each tree in the forest:

k <- 209 #tried here distinct values from 1 to 500
tree <- getTree(RF_Model, k, labelVar = TRUE)

and as the result, tree returns the tree with 19-27 levels of depth, and always all the 15 attributes are used for the tree. one of the trees and distinct attributes which are used in it

What I am doing wrong or misunderstood? Why for the small trees in the forest (No. of variables tried at each split: 3) have been used not 3 distinct attributes, but always all 15?

$\endgroup$
2
$\begingroup$

Each object, which uses in that model, has 15 attributes. In my understanding (the basic knowledge I have got from https://www.listendata.com/2014/11/random-forest-with-r.html): mtry = number of random variables used in each tree. So, I thought, that for each sample decision tree (from those 500 trees in the forest) will be used only 3 different attributes from 15.

This is incorrect. mtry is the number of variables tried at each split. A nice introduction to can be found in Elements of Statistical Learning.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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