Python, PyDot e DecisionTree

Estou tentando visualizar meu DecisionTree, mas obtendo o erro O código é:

X = [i[1:] for i in dataset]#attribute
y = [i[0] for i in dataset]
clf = tree.DecisionTreeClassifier()

dot_data = StringIO()
tree.export_graphviz(clf.fit(train_X, train_y), out_file=dot_data)
graph = pydot.graph_from_dot_data(dot_data.getvalue())
graph.write_pdf("tree.pdf")

E o erro é

Traceback (most recent call last):
if data.startswith(codecs.BOM_UTF8):
TypeError: startswith first arg must be str or a tuple of str, not bytes

Alguém pode me explicar qual é o problema? Muito obrigado!

questionAnswers(3)

yourAnswerToTheQuestion