我一直在python上运行脚本来制作决策树
from sklearn import tree
model = tree.DecisionTreeClassifier()
model = model.fit(X,Y)
然后我想在png文件中可视化结果,所以我运行了以下
from sklearn.externals.six import StringIO
import pydotplus
from IPython.display import Image
dot_data = StringIO()
tree.export_graphviz(model, out_file=dot_data,filled=True, rounded=True, special_characters=True, leaves_parallel=False)
graph = pydotplus.graph_from_dot_data(dot_data.getvalue())
graph.create_png()
Image(graph.write_png("tree.png"))
我正在使用Anaconda,所以我在Anaconda提示中运行以下命令来安装Pydotplus和Graphviz:
conda install -c conda-forge pydotplus
conda install graphviz
然而,在此之后,我收到以下错误,我不知道它来自哪里
Traceback (most recent call last):
File "<ipython-input-2-4578c1902391>", line 1, in <module>
graph.create_png()
File "C:\Users\ferlandf\AppData\Local\Continuum\anaconda3\lib\site-packages\pydotplus\graphviz.py", line 1797, in <lambda>
lambda f=frmt, prog=self.prog: self.create(format=f, prog=prog)
File "C:\Users\ferlandf\AppData\Local\Continuum\anaconda3\lib\site-packages\pydotplus\graphviz.py", line 2032, in create
status, stderr_output))
InvocationException: Program terminated with status: 3221225477. stderr follows: []
有人知道如何解决这个问题吗?
非常感谢您的帮助