【发布时间】:2019-04-09 04:55:48
【问题描述】:
使用 Google Colab 可视化决策树的最佳方法是什么? 'dtreeviz'(例如Github)的可视化效果非常简洁,但是在运行类似
的东西时!pip install dtreeviz
和
from sklearn.datasets import *
from sklearn import tree
from dtreeviz.trees import *
紧随其后
classifier = tree.DecisionTreeClassifier(max_depth=4)
cancer = load_breast_cancer()
classifier.fit(cancer.data, cancer.target)
viz = dtreeviz(classifier,
cancer.data,
cancer.target,
target_name='cancer',
feature_names=cancer.feature_names,
class_names=["malignant", "benign"],
fancy=False )
viz.view()
我明白了
ExecutableNotFound: failed to execute ['dot', '-Tsvg', '-o', '/tmp/DTreeViz_62.svg', '/tmp/DTreeViz_62'], make sure the Graphviz executables are on your systems' PATH
通过我的 g-drive 运行的 Colab 可以做哪些事情?
任何帮助表示赞赏!
【问题讨论】:
-
你试过
!apt-get install graphviz吗? -
@MaximilianPeters,谢谢 - 我现在试过了。仍然没有返回可视化 - 但现在也没有错误消息。
-
哈,我们到了!你可以试试
from IPython.core.display import display, HTML; display(HTML(viz.svg())吗? -
天哪,坚持不懈的顶级人物。而且......你已经解决了!我在您的代码末尾添加了一个“)”。
标签: scikit-learn visualization google-colaboratory decision-tree dtreeviz