【发布时间】:2019-06-12 03:03:19
【问题描述】:
我可以使用 graphviz 生成决策树图,但是当我尝试保存它时(即 out_file)
我收到以下错误:
CalledProcessError:命令 '['dot', '-Tsvg']' 返回非零退出 状态 1。
这是我的代码:
# create plot for decision tree
dot_data = tree.export_graphviz(model,
out_file='tree.dot', # this is what triggers the error
feature_names=X_test.columns,
class_names=['Active','Churned'])
graph = graphviz.Source(dot_data)
# view plot
graph
out_file 参数是触发错误的参数。我认为这应该是一个非常简单的解决方案,但我没有从搜索中找到答案。
提前谢谢你。
【问题讨论】:
-
尝试重新安装软件包。例如,在此处查看答案:stackoverflow.com/questions/50362780/…
-
感谢您的回复,但遗憾的是它并没有解决我的问题。
标签: python plot scikit-learn graphviz decision-tree