生成可視化決策樹遇到的 GraphViz's executables not found

Scikit的官網(wǎng)上 ,找到的生成可視化的決策樹的代碼如下:


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") 
    

運(yùn)行報(bào)錯(cuò)如下:

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

  1. 安裝GraphViz可以解決。通過 brew install graphviz 命令安裝。

  2. 安裝完成后重啟IDE ,就可以生成可視化的pdf和png了。

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

推薦閱讀更多精彩內(nèi)容