I am currently building a tree, with 10 features but setting max_depth = 2
in sklearn.tree.DecisionTreeClassifier
.
Since only tree features are explicitly used to make predictions I wondered about dropping uneeded columns.
Counter-intuitively, the absence of just 1 of the 7 variables not highlighted by the tree is enough to change the accuracy of the predictions, albeit marginally.
Looking around I found that
Variables that are not used in any split can still affect the decision tree [...] It is possible for a variable to be used in a split, but the subtree that contained that split might have been pruned.
However, max_depth
does not technically prune according to one answer on this website.
So what could be the reason?
y
variable has how many classes? $\endgroup$