I expected this code to create a PDF graph of the tree.
from sklearn import datasets,tree
import StringIO
import pydot
from sklearn.externals.six import StringIO
iris = datasets.load_iris()
clf = tree.DecisionTreeClassifier()
clf = clf.fit(iris['data'],iris['target'])
dot_data = StringIO.StringIO()
tree.export_graphviz(clf, out_file=dot_data)
graph = pydot.graph_from_dot_data(dot_data.getvalue())
graph.write_pdf("iris.pdf")
Is there a way to do what I want though pydot? This way is a dead end.
Explaining the problem further, the code fails in the last statement. graph.write_pdf() is looking for Graphviz in graph.progs() but there are no entries there. The error message says Graphviz executable not found.
Anyhow I was able to pdf file by invoking the dot.exe command in a DOS terminal, but it would be better to use pydot to do this step.