In cost-complexity pruning, the cost of a tree is , where is the training error rate and the number of leaves. Node (as a leaf) has , and the subtree below it has 4 leaves with total error . Node in another branch has , and its subtree has 2 leaves with . At what is each pruned, which goes first, and how is chosen?
Supervised learning, Pruning
Level L2 Elementary. Length Medium. Nature Th+Mat Both.
What's being asked
Whether you can compute the weakest-link for a node and explain how pruning produces a nested sequence of trees.
Key idea
A subtree is worth keeping while . The break-even value is : the error saved per extra leaf.
Steps
- Collapsing to a leaf changes the cost from to . They are equal when .
- Node : .
- Node : .
- Weakest link: the smallest is pruned first. So goes at and at . At only has been collapsed.
- Repeat (recompute the values on the pruned tree) to get a nested sequence of trees root.
- Choose by -fold cross-validation: pick the one with the lowest validation error, often with the 1-standard-error rule to prefer the smaller tree. Then use that on the full data. We must not choose it using training error, because that always prefers .
Common mistakes
- Dividing by instead of .
- Choosing by training error, which always favours the biggest tree.
- Forgetting to recompute after a prune, since the parent's subtree changes.
How long your answer should be
A short paragraph and 3 lines of arithmetic.
Read this
Previous in Supervised learning: A regression tree is grown on with . Which threshold does the first split choose using the sum of squared errors (SSE), and what are the leaf predictions and the SSE reduction?
Next in Supervised learning: In stacking, a meta-learner is trained on the predictions of base models. Why must the meta-features be out-of-fold predictions, and how are they produced with 5-fold cross-validation for 3 base models? What goes wrong if you use the base models' predictions on their own training data?