决策树显示不是我想要的

时间:2018-04-07 11:19:07

标签: python machine-learning scikit-learn decision-tree

我试图正确显示决策树;我非常接近,但我无法正确显示课程。

当我使用class_names = True时,我得到了这个:

enter image description here

我如何解释class = y [1]?

以下是更详细的信息:

enter image description here

enter image description here

请注意图像被剪裁,但它会沿着相同的线继续。

然后:

clf.fit(X, Y)
dot_data = tree.export_graphviz(clf, out_file=None, feature_names=combo.columns[2:], class_names=class_names)
graph = graphviz.Source(dot_data)
graph.render('r')

产生这样的输出,我知道这是错误的,因为5次出现的唯一等级是A。

enter image description here

有什么问题?

相关链接

https://datascience.stackexchange.com/questions/28574/decisiontreeclassifier-object-has-no-attribute-importances是一个有趣的答案,有一些有用的提示,但根本没有回答我在这里提出的问题。

1 个答案:

答案 0 :(得分:0)

我找到了这个解决方案:

http://my_server/api?filter=[{%22field%22:%22some_field%22,%22value%22:%22some_value%22,%22operator%22:%22%3D%22}]

事实证明,在拟合调用的结果上有一个稍微难以找到的属性:clf = tree.DecisionTreeClassifier(max_depth=4) clf.fit(X, Y) dot_data = tree.export_graphviz(clf, out_file=None, feature_names=Xprep.columns, class_names=clf.classes_) 包含类的文本再现。

相关问题