美文网首页
生成可视化决策树遇到的 GraphViz's executabl

生成可视化决策树遇到的 GraphViz's executabl

作者: 恩熙爸爸灬 | 来源:发表于2017-12-03 21:32 被阅读0次

Scikit的官网上 ,找到的生成可视化的决策树的代码如下:


from IPython.display import Image
import pydotplus

dot_data = sklearn.tree.export_graphviz(clf, out_file=None,
    feature_names=iris.feature_names,
    class_names=iris.target_names,
    filled=True, rounded=True,
    special_characters=True)

graph = pydotplus.graph_from_dot_data(dot_data)
graph.write_pdf("iris.pdf") 
    

运行报错如下:

pydotplus.graphviz.InvocationException: GraphViz's executables not found

  1. 安装GraphViz可以解决。通过 brew install graphviz 命令安装。

  2. 安装完成后重启IDE ,就可以生成可视化的pdf和png了。

相关文章

网友评论

      本文标题:生成可视化决策树遇到的 GraphViz's executabl

      本文链接:https://www.haomeiwen.com/subject/ipmzbxtx.html