import pandas as pd
from sklearn import tree
data = pd.read_table('iris.txt')
variables = ['Sepal.Length', 'Sepal.Width', 'Petal.Length', 'Petal.Width']
classifier = tree.DecisionTreeClassifier(min_samples_leaf=3, max_depth=3)
classifier = classifier.fit(data[variables], data['Species'])
with open('graph.dot', 'w') as f:
f = tree.export_graphviz(classifier, out_file=f, feature_names=variables)