Is there a way to see the order of nodes categorizing data in decision trees when not allowed to install graphviz nor pydotplus?

江枫思渺然 提交于 2019-12-13 03:18:36

问题


I need to know the order of the nodes and the scores for each one, once I have ran the decision tree model. As I'm working in my office computer, the installations are very restricted and I'm not allowed to download graphviz nor pydotplus.

It doesn't matter that there is no graphic representation of the model; I just want to know the classification order/process the algorithm is using. I'm using sklearn.tree, sklearn.metrics, and sklearn.cross_validation.


回答1:


You can make use of plot_tree of sklearn.tree module, I have illustrated an example below for your reference:

from sklearn.datasets import load_iris
from sklearn import tree
clf = tree.DecisionTreeClassifier(random_state=0)
iris = load_iris()

clf = clf.fit(iris.data, iris.target)
tree.plot_tree(clf, filled=True)

Sample Output

Hope this helps!



来源:https://stackoverflow.com/questions/57718309/is-there-a-way-to-see-the-order-of-nodes-categorizing-data-in-decision-trees-whe

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!