Reputation: 1
I am trying to use scinkit-learn's apply function for the RandomForestTreeRegressor to obtain the leaf indices for each learned tree for some data. I have specified a max_depth of 3, which should result in a maximum leaf index of 4, but I am actually getting number much higher indices in the 40s. Is there any explanation for this?
I figured maybe something was wrong with my data, so I tried the same with the sample code on scikit's page and found the same issue. If you want to reproduce it, you can edit the source code here: http://bit.ly/1GHz1iG
Upvotes: 0
Views: 316
Reputation: 28768
The indices actually go over all nodes in the tree, not only the leaves. There are up to 2 ** max_depth
leaves (which would be 8 in your case, not sure why you expect 4). As all nodes are numbered, though, the numbers can go up to 2 ** (max_depth + 1) - 1
Upvotes: 1