Tutorials › Exam PA - Predictive Analytics › Pre-Pruning With Tree-Growth Stopping Rules

Exam PA · Single Trees and Rule-Based Prediction · Tutorial 502 of 966

Pre-Pruning With Tree-Growth Stopping Rules

Understand how pre-pruning rules stop tree growth and recognize when an apparently sensible early stop may conceal useful predictive structure.

Intermediate 10 min read

What You'll Learn

  • Define pre-pruning and distinguish a local stopping decision from stopping the entire tree.
  • Calculate regression split improvement from parent and child sums of squared errors.
  • Calculate classification split improvement using weighted Gini impurity.
  • Apply a minimum-improvement rule and interpret what happens when a split fails it.
  • Explain how an early stopping rule can hide an interaction that requires successive splits.
  • Identify common calculation and interpretation traps when evaluating stopping rules.

Why Stop a Tree While It Is Growing?

A tree-growing algorithm considers candidate splits at a node and selects one according to a criterion such as reduction in squared error for a regression tree or reduction in impurity for a classification tree. A stopping rule can prevent a candidate split from being made. This limits growth before the tree has developed its full structure, rather than allowing growth and then removing parts afterward.

This early restriction is called pre-pruning. It can save computation and discourage splits that offer little immediate improvement. But a rule that is too restrictive can stop growth before the tree discovers a useful pattern. In particular, a predictor may be valuable only after another split has formed the right subgroup.

Definition: A pre-pruning stopping rule is a condition applied during tree growth that prevents a proposed split at a node, or prevents further growth under that node. The decision is local: a split rejected at one node does not necessarily prevent a different branch from continuing to grow. A rule that stops a tree because no available split satisfies its conditions is different from a later procedure that removes branches from an already grown tree.

Typical stopping conditions include the absence of any valid candidate split, no positive reduction in the chosen loss or impurity measure, or failure to meet a specified minimum improvement. Some implementations offer additional growth controls; their exact meanings and scales depend on the software and the chosen tree method. A threshold should therefore be interpreted using the implementation’s definition, not assumed to be a universal quantity.

Measure the Improvement at a Node

A stopping rule based on improvement requires a way to compare the parent node with the proposed child nodes. For regression, let the response values in a node be \(y_1,\ldots,y_n\), and let the node prediction be their mean. The node’s sum of squared errors (SSE) is the sum of squared differences between the observed values and that mean. For a proposed split into children \(j=1,\ldots,J\), define the improvement as the parent SSE minus the sum of the child SSEs.

$$ \Delta_{\text{SSE}} = \operatorname{SSE}_{\text{parent}} - \sum_{j=1}^{J}\operatorname{SSE}_{j}. $$

For classification, one common criterion is Gini impurity. If a node has class proportions \(p_1,\ldots,p_K\), its Gini impurity is \(1-\sum_{k=1}^{K}p_k^2\). For a proposed split, the child impurities must be weighted by the proportion of observations sent to each child. The improvement is parent impurity minus this weighted child impurity.

$$ \Delta_{\text{Gini}} = G_{\text{parent}} - \sum_{j=1}^{J}\frac{n_j}{n}G_j, \qquad G=1-\sum_{k=1}^{K}p_k^2. $$

These improvements are tied to the selected criterion. A minimum SSE reduction is measured in squared response units, while a Gini reduction is dimensionless. A numerical threshold used with one criterion cannot be transferred automatically to another.

Why the Improvement Formula Works

For regression, the child-node means are the predictions that minimize squared error within their respective children. The reduction in SSE therefore measures how much better those separate predictions fit the training responses than the single parent prediction. To see the decomposition, let \(\bar y\) be the parent mean and \(\bar y_j\) the mean in child \(j\). Within child \(j\), write each deviation as \(y_i-\bar y=(y_i-\bar y_j)+(\bar y_j-\bar y)\). On squaring and summing, the cross-product is zero because the deviations \(y_i-\bar y_j\) sum to zero in that child. Thus:

$$ \sum_{i=1}^{n}(y_i-\bar y)^2 = \sum_{j=1}^{J}\sum_{i\in j}(y_i-\bar y_j)^2 + \sum_{j=1}^{J}n_j(\bar y_j-\bar y)^2. $$

The first term on the right is the total child SSE. The remaining term is nonnegative, so splitting cannot increase training SSE when each child is predicted by its own mean. A minimum-improvement stopping rule does not ask only whether improvement is possible; it asks whether the improvement is large enough to satisfy its specified condition.

For classification, the weighted child impurity is the expected impurity after assigning an observation to its child: child \(j\) receives weight \(n_j/n\). Subtracting that expected impurity from the parent impurity gives the split’s improvement under the chosen measure. Weighting is essential because a child containing one observation should not count as much as a child containing many observations.

Worked Example: A Regression Split Just Below the Required Gain

A hypothetical tree is evaluating a split of six observations with response values \(2,2,4,4,8,8\). The candidate split puts the first four observations in one child and the last two in another. The stopping rule requires an absolute SSE reduction of at least 35. Decide whether the split is accepted.

Method. Calculate the parent SSE, calculate each child SSE, and compare their difference with the required improvement of 35.

The parent mean is \((2+2+4+4+8+8)/6=28/6=14/3\). The parent SSE is \[ 2(2-14/3)^2+2(4-14/3)^2+2(8-14/3)^2 =2(64/9)+2(4/9)+2(100/9)=336/9=112/3. \]

The first child has values \(2,2,4,4\) and mean \(3\). Its SSE is \[ (2-3)^2+(2-3)^2+(4-3)^2+(4-3)^2=4. \]

The second child has values \(8,8\) and mean \(8\), so its SSE is \(0\). The total child SSE is \(4+0=4\). The improvement is \[ 112/3-4=112/3-12/3=100/3\approx 33.3333. \]

Since \(100/3\approx33.3333<35\), the proposed split fails this stopping rule. If the required minimum were 30 instead, the same split would pass because \(100/3>30\). The calculation is checked by the decomposition: the reduction is positive, but it is smaller than the specified threshold of 35.

Common mistake avoided: Treating any positive reduction as sufficient. Under this stated rule, a reduction must meet the minimum, not merely exceed zero. The threshold is also in squared response units, so its size must be interpreted in the context of the response scale.

When a Local Stop Hides an Interaction

A greedy tree usually assesses a split by its immediate improvement at the current node. This makes stopping rules particularly consequential when the predictive pattern depends on an interaction: the value of one predictor changes according to the value of another. The first split may show no improvement on its own, even though a second split would separate the outcomes effectively.

Worked Example: A Zero-Gain First Split Conceals a Useful Pattern

A hypothetical classification data set has eight observations, with two observations at each combination of binary predictors \(A\) and \(B\). The outcome is class 1 when \(A\) and \(B\) differ, and class 0 when they are equal. A pre-pruning rule stops at a node if the best available split has no positive Gini improvement. Determine what happens at the root and after a hypothetical first split on \(A\).

Method. Calculate the root Gini impurity and the weighted impurity after splitting on \(A\). Then check whether splitting on \(B\) would be useful inside either child.

There are four class 0 observations and four class 1 observations at the root, so \(p_0=p_1=1/2\). The root impurity is \[ G_{\text{root}}=1-(1/2)^2-(1/2)^2=1/2. \]

In the child \(A=0\), the two observations with \(B=0\) are class 0 and the two with \(B=1\) are class 1. The child therefore has two observations of each class, giving Gini impurity \(1/2\). The child \(A=1\) also has two observations of each class, so its Gini impurity is \(1/2\). Each child has four of the eight observations, and the weighted impurity is \[ (4/8)(1/2)+(4/8)(1/2)=1/2. \] The root split on \(A\) has improvement \(1/2-1/2=0\). Splitting on \(B\) at the root likewise gives zero improvement, by the symmetry of the data. The stated rule therefore stops at the root.

Now consider what would happen if a first split on \(A\) were allowed. Within each \(A\) child, splitting on \(B\) separates the two classes perfectly: each resulting leaf contains only one class, so its Gini impurity is zero. Thus, the second split would reduce that child’s Gini impurity from \(1/2\) to \(0\). A tree with the two successive splits predicts all eight training outcomes correctly, while the stopped root predicts the majority class with a tie and cannot distinguish the classes.

Common mistake avoided: Concluding from zero root improvement that the predictors contain no useful structure. Here the useful structure appears only in the combination of \(A\) and \(B\). The example does not imply that every zero-gain split should be allowed; it shows the cost that an immediate-improvement stopping rule can incur.

Apply a Classification Threshold Carefully

A minimum-improvement rule can reject a split even when it does improve the criterion. The following calculation also shows why child sizes must be used when combining classification impurities.

Worked Example: Weighted Gini Gain and a Threshold Decision

A hypothetical binary classifier considers splitting ten records into a left child with three positive and one negative outcome, and a right child with one positive and five negative outcomes. The pre-pruning rule requires a Gini improvement of at least \(0.16\). Decide whether the split passes.

Method. Compute the parent impurity, compute each child impurity, weight by child size, and compare the gain with \(0.16\).

The parent has four positives and six negatives, so \[ G_{\text{parent}}=1-(4/10)^2-(6/10)^2 =1-0.16-0.36=0.48. \]

The left child has positive proportion \(3/4\), so \[ G_L=1-(3/4)^2-(1/4)^2=1-9/16-1/16=6/16=3/8. \] The right child has positive proportion \(1/6\), so \[ G_R=1-(1/6)^2-(5/6)^2=1-1/36-25/36=10/36=5/18. \]

The weighted child impurity is \[ (4/10)(3/8)+(6/10)(5/18)=3/20+1/6=19/60. \] The improvement is \[ 0.48-19/60=12/25-19/60=144/300-95/300=49/300\approx0.1633. \]

Since \(0.1633\geq0.16\), the split passes. The calculation is checked by confirming that the weighted child impurity \(19/60\approx0.3167\) is below the parent impurity \(0.48\), and that the difference is approximately \(0.1633\).

Common mistake and correction: Averaging the two child impurities without weights gives \((3/8+5/18)/2=47/144\approx0.3264\), and an incorrect gain of \(0.48-0.3264\approx0.1536\). That would reject the split. The correction is to weight each child by its share of the observations: \(4/10\) and \(6/10\). The split passes the stated threshold.

Interpret the Stopping Decision in Context

A stopping rule is a modeling choice, not proof that no further predictive structure exists. A high threshold can produce a small, simple tree, but it can also leave the model underfit by rejecting useful splits. A very permissive threshold can allow many small improvements, including improvements that reflect noise in the training data. The appropriate choice depends on the modeling objective and should be assessed using suitable evaluation data, rather than inferred from training improvement alone.

Keep these distinctions clear when interpreting a fitted tree:

  • Local versus global: one node may stop growing while another branch continues, if the rule is applied separately at each node.
  • Improvement versus acceptability: a positive gain can still fail a minimum-gain rule.
  • Criterion and scale: SSE gains and impurity gains use different scales; even SSE thresholds depend on the response’s units.
  • Immediate versus later value: a predictor with little immediate gain may become useful after another split, particularly when an interaction is present.
  • Software meaning: package controls can use different definitions or normalizations of improvement. Interpret a setting using the software’s documented criterion and the model’s chosen loss measure.

For tree-based modeling aligned with the SOA Exam PA (Predictive Analytics) syllabus, be prepared to identify the stopping condition, calculate the relevant node-level improvement, and state the consequence of stopping. A strong explanation also notes what the rule may have excluded, without claiming that the rejected split would necessarily improve predictions on new data.

Check Your Understanding

For each problem, apply the stated criterion and keep track of whether the rule is local to a node.

  1. A regression node has parent SSE 50. A proposed split gives child SSEs of 21 and 13. The rule requires an SSE reduction of at least 15. Does the split pass? (Answer: Yes; the reduction is \(50-(21+13)=16\), which is at least 15.)
  2. A classification node has parent Gini impurity \(0.50\). A candidate split has weighted child impurity \(0.46\), and the minimum required gain is \(0.05\). Does it pass? (Answer: No; the gain is \(0.50-0.46=0.04<0.05\).)
  3. A binary classification node has five observations in each class, so its Gini impurity is \(0.50\). A proposed split creates two equal-sized children, each with three observations of one class and two of the other. Each child has Gini impurity \(1-(3/5)^2-(2/5)^2=0.48\). With a minimum gain of \(0.01\), does the split pass? (Answer: Yes; the weighted child impurity is \(0.48\), so the gain is \(0.02\).)
  4. A tree has two branches. The best candidate split in the first branch has improvement \(0.08\), while the best candidate in the second has improvement \(0.14\). The local minimum is \(0.10\). What happens? (Answer: The first branch stops, while the second branch can split because \(0.14\geq0.10\).)
  5. A regression split has SSE improvement 12 when the response is measured in its original units. Suppose every response value is multiplied by 3, and the stopping rule still requires an absolute SSE improvement of 20. What is the new improvement, and does it pass? (Answer: The improvement becomes \(3^2(12)=108\), so it passes the unchanged threshold of 20.)
Clinical Biostats