skip to content

Why can a decision tree's pre-pruning rules reject a split that post-pruning would keep?

level: middleimportance: nice to knowfreq 30%

answer

  1. greedy sees one split ahead
  2. value can hide one level deeper
  3. think of interacting features
  4. grow first, then judge the whole subtree
  5. the cost of fixing it is compute

basics

~10 s

Pre-pruning judges each split on its immediate gain with no lookahead, so a near-worthless split that unlocks a strong one a level below is refused. Post-pruning grows first and judges the pair together.

solid answer

~50 s

This is the horizon effect. Tree growth is greedy with one-step lookahead, so a minimum-impurity-decrease or depth rule scores a candidate split only by what it buys right now. Consider a split at depth 3 that barely moves impurity but partitions the data so that a depth-4 split becomes highly informative — the classic case is two interacting features where neither is predictive alone. Pre-pruning refuses the depth-3 split, growth on that branch ends, and the depth-4 gain is never discovered. Post-pruning avoids this because it grows the tree to (or near) purity first: when it later asks whether to collapse the depth-3 node, the comparison is against the *whole subtree beneath it*, whose error saving is large, so the node survives. The price is compute — you build a tree you mostly throw away — which is why pre-pruning still wins on very large data.

go deeper

for a junior

Know the two strategies by name: stop growth early with limits, or grow fully and cut back afterwards. Remember that the second one can keep a split the first would have refused.

for a middle

Explain the horizon effect mechanically — one-step-lookahead scoring, a weak split at one depth enabling a strong one below, and why comparing against the whole subtree during pruning rescues it.

for a senior

Argue the tradeoff on a real workload: when growing to purity is affordable, when a leaf-size floor is a domain requirement rather than a hyperparameter, and how to combine loose pre-pruning with cost-complexity pruning without one silently overriding the other.

for a principal

Frame it as a compute-versus-model-quality policy decision across many models: what training budget you are willing to standardise on, and whether the interactions your domain actually contains justify paying to grow trees you mostly discard.

## Greedy growth has a one-split horizon A decision tree is built by recursive greedy search. At each node the algorithm scores every candidate cut by the impurity it removes *immediately*, takes the best one, and recurses. It never asks what would become possible two splits later. That is what makes tree fitting fast, and it is also its structural weakness. Now layer a stopping rule on top. A minimum-impurity-decrease threshold, a depth cap, or a minimum node size all ask the same kind of question: is this split, on its own, worth making? For most nodes the answer is a fair proxy for whether the branch is worth growing. But not always. ## The failure case Suppose at depth 3 the best available split moves Gini by almost nothing — it separates the rows into two halves that are just as mixed as the parent. Under a minimum-impurity-decrease threshold, the split is refused and the node becomes a leaf. But suppose that split, useless as it is by itself, isolates a region in which a *fourth* feature suddenly separates the classes cleanly. The depth-4 split would have been excellent. It is never evaluated, because its parent was never made. This is the **horizon effect**: the payoff lies just beyond the depth the stopping rule can see. The canonical structure behind it is an interaction. With an XOR-shaped relationship — the target is positive when exactly one of two binary features is on — neither feature alone reduces impurity at all, because each leaves both classes evenly mixed on both sides. Only the *combination* is informative. A greedy scorer sees two useless features; a stopping rule then confirms that verdict and closes the branch. Real data shows softer versions of this constantly: a segment flag that is uninformative overall but changes what a price threshold means inside one segment. ## Why post-pruning does not have this problem Cost-complexity pruning grows the tree first, then decides what to remove. When it evaluates the depth-3 node, the quantity that matters is the error of the *entire subtree rooted there* versus the error of collapsing it to a leaf. The strong depth-4 split is inside that subtree, so the saving is large, the break-even price per removed leaf is high, and the node is not a weak link. It survives — along with the useless split that made it reachable. Put in one line: pre-pruning evaluates a split in isolation before its children exist; post-pruning evaluates a node together with everything it enabled. ## The tradeoff, honestly stated Post-pruning is not free. - **Compute and memory.** You grow a tree to purity and then discard most of it. On tens of millions of rows, or on data where a fully grown tree does not fit in memory, that is not a reasonable bill to pay. Pre-pruning saves exactly the work that post-pruning wastes, because a refused split removes an entire subtree's worth of candidate scanning. - **Simplicity of tuning.** Pre-pruning limits are direct and interpretable ("no leaf below 50 patients"), and can be dictated by domain requirements rather than tuned at all. Cost-complexity alpha has to be selected on held-out data and is measured on the error scale of the specific problem. - **Statistical honesty.** Post-pruning's later comparison is made on the same training data unless you cross-validate it, which is why alpha selection needs held-out folds. A leaf-size floor needs no such machinery. Could pre-pruning be given lookahead? In principle yes — evaluate the best two-level combination at each node instead of the best single split. In practice the candidate count multiplies, the cost becomes prohibitive on wide data, and it only pushes the horizon out by one level; a three-deep interaction defeats it again. That is why the standard answer to the horizon effect is post-pruning rather than deeper lookahead. ## How they combine The two are not mutually exclusive, and production practice often mixes them: keep loose pre-pruning limits so the full tree remains buildable and no leaf is absurdly small, then apply cost-complexity pruning on top and choose alpha by cross-validation. The discipline is to keep the pre-pruning limits loose enough that they are not silently making the pruner's decisions for it. If your depth cap is 4 and the pruner never removes anything, the depth cap is your model-selection procedure and alpha is decoration. ## What interviewers are listening for The insight to voice is that greedy search and greedy stopping compound: the split scorer is myopic, and a stopping rule built on that same myopic score inherits the blind spot. Candidates who can name the interaction case, say why the subtree comparison fixes it, and then concede the compute cost of growing first have given the complete answer.

  • Can pre-pruning be given lookahead to solve this?
    Technically yes: score the best two-level combination at each node rather than the best single split. But the number of candidate pairs multiplies, which is expensive on wide data, and it only moves the horizon one level — a three-way interaction defeats it again. Growing fully and pruning back is the cheaper and more general fix.
  • When would you still choose pre-pruning despite the horizon effect?
    When growing the full tree is impractical or wasteful: very large datasets, tight training-time budgets, or memory limits. Also when the constraint is a domain requirement rather than a tuning choice — if no decision rule may rest on fewer than 50 patients, a leaf-size floor states that directly and needs no validation folds to justify.
  • Do you have to choose one strategy or can you use both?
    Both is common: keep loose pre-pruning limits so the tree is buildable and no leaf is absurdly small, then apply cost-complexity pruning and choose alpha on held-out folds. The discipline is keeping the pre-pruning loose. If a tight depth cap means the pruner never removes anything, the cap is doing your model selection and the pruning step is decoration.

Like refusing a chess move that looks pointless without checking the reply it forces two moves later.

saying these in an interview costs you the question

  • Says greedy split search evaluates whole subtrees
  • Claims pre-pruning and post-pruning always give the same tree
  • Thinks post-pruning is strictly better with no cost
  • Cannot name a case where a weak split enables a strong one
  • Believes a depth cap can capture interactions if data is large enough

context