Reputation:
I've a random forest classifier in Python with default parameters. After the classifier is built is it possible to find the max depth in random forest classifier ?
For decision tree classifier we have tree.max_depth().
Example : this
I know we can set max_depth in Random forest classifier but given a classifier with default values can we get this max_depth ? Please help.
Upvotes: 2
Views: 972
Reputation: 2851
All the trees are accessible via estimators_
attribute, so you should be able to do something like:
max((e.tree_.max_depth for e in rf.estimators_))
(assuming rf
is a fitted instance of a RandomForestClassifier
)
Upvotes: 1