简体   繁体   English

决策树图不起作用 python 3.6 不保存

[英]Decision trees graph not working python 3.6 not saving

I am trying to print s decesion tree in python but for some reason i am getting an error message:我正在尝试在 python 中打印 s decesion 树,但由于某种原因,我收到一条错误消息:

InvocationException: GraphViz's executables not found InvocationException: 找不到 GraphViz 的可执行文件

import graphviz
tree = DecisionTreeClassifier(criterion='entropy',max_depth=18,random_state=0)
tree.fit(X_train, y_train)
dot_data = StringIO()
export_graphviz(tree,out_file = dot_data,filled=True,rounded=True,feature_names=X_train.columns.values.tolist(),class_names = ['0', '1'],special_characters=True)
graph = pydotplus.graph_from_dot_data(dot_data.getvalue())
graph.write_png("C:/Temp/Tree.png")
print('Visible tree plot saved as png.')
graph

You need to add graphviz to PATH.您需要将graphviz添加到 PATH。 Find your own version of this:找到你自己的版本:

C:\Users\Env\Library\bin\graphviz

And add it to PATH.并将其添加到 PATH。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM