#!dt/bin/python3 from sklearn import tree import pydotplus X=[[0,0],\ [0,1],\ [1,0],\ [1,1]] Y=[0,0,0,1] clf = tree.DecisionTreeClassifier() clf = clf.fit(X, Y) # dump decision tree dot_data = tree.export_graphviz( clf, out_file=None, filled=True, rounded=True, feature_names=['X','Y'], class_names=['0','1']) graph = \ pydotplus.graph_from_dot_data(dot_data) graph.write_png("tree.png") # Check predictions for input in X: print( input, ":", clf.predict( [input] ) )