Search code examples
scikit-learndecision-tree

Report the depth and number of leaves of the learned tree of DecisionTreeClassifier in scikit-learn


How to extract the depth and number of leaves of the learned tree of DecisionTreeClassifier in scikit-learn?

https://scikit-learn.org/stable/modules/generated/sklearn.tree.DecisionTreeClassifier.html


Solution

  • Depth of learned tree and number of leaves can be extracted using clf.get_depth() and clf.get_n_leaves() functions respectively.