当不允许安装 graphviz 或 pydotplus 时,有没有办法查看节点在决策树中对数据进行分类的顺序?

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

一旦我有了 运行 决策树模型,我就需要知道节点的顺序和每个节点的分数。由于我在办公室电脑上工作,安装非常受限,不允许我下载 graphviz 和 pydotplus。

模型没有图示也没关系;我只想知道算法使用的分类 order/process。我正在使用 sklearn.treesklearn.metricssklearn.cross_validation

你可以使用sklearn.tree模块的plot_tree,我在下面举例说明供你参考:

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

希望对您有所帮助!