GraphViz‘s executables not found 简化版解决方案

机器学习中,提示 GraphViz找不到

python 代码中,提示GraphViz找不到

python中,提示GraphViz's executables not found

人工智能学习决策树时,遇到 GraphViz's executables not found

———————————————————————————————————————————

链接:百度云盘提取链接
提取码:kai9

下载这个安装包就完事了,很小,哪怕是百度云盘那个网速,也一会儿就好了。

使用,下载好以后,直接点击安装,然后放在默认路径下。

然后,

如果你是用的 Jupyter Notebook,安装好以后,删掉已经生成的.jpg,就下面这个

然后关闭Jupyter的浏览器页面和后台启动的程序,就

是下面这个。然后重新点击这个启动,打开notebook浏览器页面,挨个运行一遍就好了。

如果你用的PyCharm ,那就是直接重启PyCharm。

除此以外,如果你只是想要这个决策树生成图形,可以只放下面这段代码,它可以直接给你输出图形,

# 可直接输出图形
fn=['sepal length (cm)','sepal width (cm)','petal length (cm)','petal width (cm)']
cn=['setosa', 'versicolor', 'virginica']
fig, axes = plt.subplots(nrows = 1,ncols = 1,figsize = (2,2), dpi=300)
tree.plot_tree(tree_model,
rounded=True,
               feature_names = fn, 
               class_names=cn,
               filled = True)
plt.show()

图形如下,很鲜艳