machine learning - How to find out the size of a sklearn decision tree in python? -


I am adding some specialty with decision trees and in terms of the number of nodes, I want to know the size of the tree. How can I do this in a dragon?

Using stock example from Schenene's website,

  x = [[0,0], [0,1]] y = [0,1] sklearn RandomForestClassifier clf = RandomForestClassifer (n_estimators = 10) clf = clf.fit (x, y) from .esemble import  

I can do something like clf to individual trees [1], clf [...], but how can I determine the size of each tree in terms of the total node number?

A sklearn.tree._tree.Tree object has a 'node_count' property:

  Scalean import from tree X = [[0, 0], [1, 1]] Y = [0, 1] clf = tree.DecisionTreeClassifier () clf = clf.fit (x, y) tree Obz = clf.tree_ print tree obz.node_ count  

Comments

Popular posts from this blog

java - Can't add JTree to JPanel of a JInternalFrame -

javascript - data.match(var) not working it seems -

javascript - How can I pause a jQuery .each() loop, while waiting for user input? -