I was trying to solve an XOR problem, and the dataset seems like the one in the image.
I plotted the tree and got this result:
As I understand, the tree should have depth 2 and four leaves. The first comparison is annoying, because it is close to the right x border (0.887). I've tried other parameterizations, but the same result persists.
I used the code below:
from sklearn.tree import DecisionTreeClassifier clf = DecisionTreeClassifier(criterion='gini') clf = clf.fit(X, y) fn=['V1','V2'] fig, axes = plt.subplots(nrows = 1,ncols = 1,figsize = (3,3), dpi=300) tree.plot_tree(clf, feature_names = fn, class_names=['1', '2'], filled = True);
I would be grateful if anyone can help me to clarify this issue.