当不允许安装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。
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.
没有关系没有模型的图形表示;我只想知道算法使用的分类顺序/过程。我正在使用 sklearn.tree
, sklearn.metrics
和 sklearn.cross_validation
。
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
.
推荐答案
您可以使用 plot_tree
sklearn.tree
模块的示例,我在下面说明了一个示例供您参考:
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
希望这会有所帮助!
这篇关于当不允许安装graphviz或pydotplus时,是否有办法查看节点在决策树中对数据进行分类的顺序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!