[英]Using sklearn, how do I find depth of a decision tree?
I am training a decision tree with sklearn.我正在用 sklearn 训练决策树。 When I use:
当我使用:
dt_clf = tree.DecisionTreeClassifier()
Access the max_depth
for the underlying Tree
object: 访问底层
Tree
对象的max_depth
:
from sklearn import tree
X = [[0, 0], [1, 1]]
Y = [0, 1]
clf = tree.DecisionTreeClassifier()
clf = clf.fit(X, Y)
print(clf.tree_.max_depth)
>>> 1
You may get more accessible attributes from the underlying tree object using: 您可以使用以下方法从基础树对象获取更多可访问的属性:
help(clf.tree_)
These include max_depth
, node_count
, and other lower-level parameters. 这些包括
max_depth
, node_count
和其他较低级别的参数。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.