[英]Saving Graphviz decision tree plot using Scikit Learn DecisionTreeClassifier
我可以使用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
參數是觸發錯誤的參數。 我認為這應該是一個非常簡單的解決方案,但是我沒有從搜索中找到答案。
先感謝您。
您應該在tree.export_graphviz()的末尾添加參數“ out_file = None” 。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.