2
$\begingroup$

I am trying to find out how to determine / display the mode of the decision trees (used by Random Forest to make further predictions / assignments). I am using library(randomForest) in R:

r <- randomForest(Species ~., data=train.set, importance=TRUE, do.trace=100, ntree=100)

I can extract a given tree using t <- getTree(r, k=2) where k is the tree number. However, in my understanding, Random Forest is using the mode of these trees to classify new items.

How can I access this, and perhaps display a final decision tree?

$\endgroup$
4
  • $\begingroup$ >"However, in my understanding, Random Forest is using the mode of these trees to classify new items. How can I access this, and perhaps display a final decision tree?" Do you mean you want predict? $\endgroup$ – Sycorax Aug 26 '16 at 20:32
  • $\begingroup$ I am looking for a generally digestible way for reporting the results to an audience typically used to regression coefficients and linear weights, etc. I know I can display Mean Decrease Gini, but I was wondering if there was a way to illustrate the RF output using a decision tree illustration $\endgroup$ – ollama Aug 26 '16 at 23:21
  • $\begingroup$ I'd just use a single tree as an example, and explain that there are many such trees, each different. $\endgroup$ – Sycorax Aug 26 '16 at 23:24
  • $\begingroup$ it is an ensemble so you get a weighted average. If you want the individual results then you can use get tree to get individuals out and look at their individual predictions. $\endgroup$ – EngrStudent Sep 5 '16 at 16:29
6
$\begingroup$

There is no final decision tree. When you predict with a Random Forest, the data is presented to every tree and in your example, each tree reaches a decision on Species, which is one of three possibilities: Versicolor, Virginica, or Setosa. When your 500 trees have each decided, the mode (most common answer) is chosen as the forest's decision.

So the mode is the mode of the decisions. There is no mode of the trees. (I doubt that any two trees are the same, and defining a mode of trees that doesn't involve exact duplicates might be difficult.)

$\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.