Python Decision Tree code not producing Image

10 views
Skip to first unread message

AENB2016

unread,
Dec 11, 2019, 5:13:01 PM12/11/19
to spyder
Hello,

I'm trying the Python Decision tree example code from this website:

All lines execute without any problems except the very last one to produce the image. When I run it I get the following error message:

InvocationException: GraphViz's executables not found

I'm pasting the full code below. 

Thanks


import sklearn.datasets as datasets
import pandas as pd
iris=datasets.load_iris()
df=pd.DataFrame(iris.data, columns=iris.feature_names)
y=iris.target


from sklearn.tree import DecisionTreeClassifier
dtree=DecisionTreeClassifier()
dtree.fit(df,y)


from sklearn.externals.six import StringIO  
from IPython.display import Image  
from sklearn.tree import export_graphviz
import pydotplus
dot_data = StringIO()
export_graphviz(dtree, out_file=dot_data,  
                filled=True, rounded=True,
                special_characters=True)
graph = pydotplus.graph_from_dot_data(dot_data.getvalue())  
Image(graph.create_png())   


Reply all
Reply to author
Forward
0 new messages