簡體   English   中英

決策樹圖不起作用 python 3.6 不保存

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

我正在嘗試在 python 中打印 s decesion 樹,但由於某種原因,我收到一條錯誤消息:

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

您需要將graphviz添加到 PATH。 找到你自己的版本:

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

並將其添加到 PATH。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM