0

I am able to generate a decision tree plot using graphviz, but when I try to save it (i.e., out_file)

I get the following error:

CalledProcessError: Command '['dot', '-Tsvg']' returned non-zero exit status 1.

Here is my code:

# 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

The out_file argument is the one that triggers the error. I'm thinking that this should be a pretty easy solution, but I have not found an answer from my searches.

Thank you in advance.

Venkatachalam
  • 16,288
  • 9
  • 49
  • 77
Aaron England
  • 1,223
  • 1
  • 14
  • 26
  • Try to reinstall the packages. For example, check answer here: https://stackoverflow.com/questions/50362780/cant-display-graphviz-tree-in-jupyter-notebook – avchauzov Jan 17 '19 at 21:25
  • Thank you for your response, but unfortunately it does not solve my problem. – Aaron England Jan 17 '19 at 22:14

1 Answers1

0

You should add a parameter "out_file = None" at the end of the tree.export_graphviz().

ZAKKI
  • 1