1
$\begingroup$

I have a big dataset with more than 100 000 observations and 12 predictors. I used the tree()-function and got the error: Error in plot.tree(tree): cannot plot singlenode tree

But with the exact same data in randomForest() I tried to look at the trees with getTree() and it said that all my trees has roughly 8000 nodes each (!)

Anyone who can explain how this can be?

$\endgroup$
1
  • 1
    $\begingroup$ It would help if you indicate what package is the tree() function from and if you share the code you used. A short description of the data would also help. For instance, what are the characteristics of the target variable? Is it binary? If so, what is the event rate? As a general suggestion, you could try to see what happens when running the same model fits on other datasets or with less observations on the same dataset to try to pin point the problem. $\endgroup$
    – mastropi
    Commented May 12, 2020 at 13:22

1 Answer 1

2
$\begingroup$

A possible explanation are different default parameters determining the size of the tree.

Random forests are based on the idea of averaging a lot of slightly different, very deep decision trees. By default, leaf nodes often contain as little as a handful of observations. A single such overfitted tree would perform very badly if applied to unseen data. Averaging a lot of unstable trees results in a quite robust model, an idea similar to economic diversification of a portfolio of highly risky single assets.

In order to make a single tree perform acceptably well, it needs to be smaller than in a random forest. Thus, default parameters are usually very different. In your case, the regularization is so strong that not a single split is made.

$\endgroup$
2
  • 1
    $\begingroup$ for R, rpart package, most the of the time, the default setup will just give me a root... need to change the cp parameter (+1 btw) $\endgroup$
    – Haitao Du
    Commented May 12, 2020 at 17:57
  • $\begingroup$ Same here @HaitaoDu :-). $\endgroup$
    – Michael M
    Commented May 12, 2020 at 19:13

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.