我有一个经过训练的决策树分类器,我想知道它有多少个叶子和节点。
它们存储在内部“tree_”对象中:
clf = DecisionTreeClassifier() clf.fit(X, y) print('Leaves:', clf.tree_.n_leaves) print('Leaves and Nodes:', clf.tree_.node_count)