Tree Pruning
Study guide: Exam MAS-II
Tree Pruning is the cutting back of a large decision tree to a subtree that predicts better on test data. A tree with more splits has lower bias but higher variance. Cost complexity pruning grows a large tree T_0 and, for a tuning parameter \alpha \ge 0, chooses the subtree T that minimizes
\sum_{m=1}^{\lvert T\rvert} \sum_{x_i \in R_m}\left(y_i - \hat{y}_{R_m}\right)^{2} + \alpha\,\lvert T \rvert
\lvert T \rvertis the number of terminal nodes ofT.R_mis the region of themth terminal node, and\hat{y}_{R_m}its mean response.
When \alpha = 0 there is no penalty, so the subtree minimizing the criterion is the full tree T_0. Raising \alpha makes each terminal node more expensive, and the tree collapses from the bottom up to a single node.
Candidate subtrees have (terminal nodes, RSS) of
(1, 520),(3, 340),(5, 285)and(8, 262). Which is chosen at\alpha = 25, and which at\alpha = 40?
- At
\alpha = 25the criteria are545,415,410and462, so the 5-node subtree is chosen.- At
\alpha = 40they are560,460,485and582, so the 3-node subtree is chosen.
Pruning an internal node
Pruning at an internal node collapses the subtree below it into one terminal node. That node's RSS replaces the summed RSS of the leaves it absorbs, and \lvert T \rvert falls by the number of those leaves minus one. So pruning a node lowers the criterion exactly when the RSS it adds is less than \alpha times the number of terminal nodes it removes.
A tree with 10 terminal nodes has RSS 50. Pruning it to 4 terminal nodes raises the RSS to 80. At
\alpha = 5, which tree is preferred?
- The full tree's criterion is
50 + 5(10) = 100.- The pruned tree's criterion is
80 + 5(4) = 100.- The two tie, so the smaller, more interpretable pruned tree is preferred.
Choosing \alpha by cross-validation
As \alpha increases, the chosen subtrees form a nested, finite sequence. Cross-validation chooses the \alpha, and so the subtree size, that minimizes the cross-validation estimate of the test error, such as the MSE. The tree is then pruned at that \alpha on the full training data.
The tree is grown large first and pruned afterwards. Stopping early when no split reduces the RSS enough is short-sighted, because a weak split can lead to a strong split below it. For a classification tree, the classification error rate is preferred for pruning when prediction accuracy of the final tree is the goal.
Ten-fold cross-validation gives estimated test MSEs of
48,41,39and44for subtrees with 2, 4, 6 and 9 terminal nodes. Which subtree is used?
- The smallest cross-validation MSE is
39, at 6 terminal nodes.- The tree is pruned to the 6-node subtree at the corresponding
\alpha, fitted on all the training data.
The full tree wins on training error At
\alpha = 0the full tree always has the smallest training RSS. The size of the tree is chosen by cross-validated error, never by training error.