I'm trying to visualize a decision tree using pydotplus. Below is the code snippet.
if image_file_name is not None:
dot_data = export_graphviz(decision_tree_model, feature_names=features,out_file=None,filled=True,rounded=True)
graph = pydotplus.graph_from_dot_data(dot_data)
colors = ('turquoise', 'orange')
edges = collections.defaultdict(list)
for edge in graph.get_edge_list():
edges[edge.get_source()].append(int(edge.get_destination()))
for edge in edges:
edges[edge].sort()
for i in range(2):
dest = graph.get_node(str(edges[edge][i]))[0]
dest.set_fillcolor(colors[i])
graph.write_png(image_file_name)
Whenever the last statement gets executed, I get this message.
Troubleshooting Steps Performed by me:
- Uninstalled both Anaconda and Python.
- Made a fresh installation of Python and Anaconda.
- Installed Graphviz and Pydotplus and added the path of Graphviz directory to system path.
- Started the Jupyter notebook terminal and tried executing the code. But still this issue is not yet fixed.
Python Version used: 3.7.1
Anaconda version used: Anaconda3-5.3.1
Can anyone please assist me from here?