简体   繁体   中英

How to find the max depth in a random forest classifier?

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.

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 )

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM