Tutorials › Exam PA - Predictive Analytics › Choosing The Number Of Boosting Iterations

Exam PA · Gradient Boosting and Tuning · Tutorial 561 of 966

Choosing The Number Of Boosting Iterations

Use training and validation loss curves to assess boosting complexity and select a defensible number of iterations.

Advanced 11 min read

What You'll Learn

  • Express a boosted model after a specified number of rounds.
  • Explain why adding rounds can reduce training loss but worsen validation loss.
  • Identify underfitting, a validation-loss minimum, and signs of overfitting.
  • Select an iteration count using a stated validation metric and tie rule.
  • Compare training and validation losses on a common per-observation scale.
  • Recognize why an iteration count depends on other fixed boosting choices.

Why the Number of Rounds Matters

A boosted-tree model is built in stages: each new tree contributes an adjustment to the model already fitted. The number of boosting rounds, often written \(M\), is the number of such updates included in the final ensemble. A small \(M\) limits the model’s ability to capture structure; a very large \(M\) can allow it to fit idiosyncrasies in the training data. The practical task is to choose a round count that predicts well on data not used to fit the trees.

This tutorial focuses on reading training and validation loss curves with the tree structure, learning rate, loss function, and other fitting choices held fixed. The discussion is aligned with the SOA Exam PA (Predictive Analytics) syllabus.

Definition: Let \(F_0(x)\) be the initial prediction and let \(h_m(x)\) be the tree contribution at round \(m\). For a fixed learning rate \(\eta\), a boosted model after \(M\) rounds can be written as $$ F_M(x)=F_0(x)+\eta\sum_{m=1}^{M}h_m(x). $$ The iteration count \(M\) is the number of tree updates included. It is a complexity control: it does not mean that each tree has \(M\) leaves or depth \(M\).

For a chosen loss function, calculate loss on both the training data and a separate validation set at successive round counts. The training loss describes fit to the observations used to build the model. The validation loss estimates predictive performance on observations withheld from tree fitting. For example, squared-error loss is appropriate for a quantitative response when squared prediction errors are the target of evaluation; logistic loss can be used for binary outcomes when probabilistic predictions are evaluated. The loss and its scale must be consistent across round counts.

Reading the Two Curves

The training objective generally falls as rounds are added when each update is chosen to reduce that objective. It need not fall strictly at every round in every implementation. Validation loss has no such guarantee: it may decrease, flatten, fluctuate, or rise. Its shape is the key evidence about whether additional rounds are improving generalization.

PatternTraining lossValidation lossInterpretation
Too few roundsRelatively highRelatively highThe model has not yet captured enough predictive structure; this is underfitting.
Useful rangeLower than at small round countsFalling or near its minimumAdded rounds are improving, or have not materially harmed, out-of-sample fit.
Too many roundsContinues to fallRises persistently after a minimumTraining fit improves while predictive performance deteriorates; this is evidence of overfitting.

A validation curve is not required to be a perfect U shape. It is calculated on a finite sample and may be noisy, so nearby rounds can trade places in measured loss. Interpret the overall pattern and the stated selection rule rather than treating every small fluctuation as a real change in predictive ability.

Key principle: Choose \(M\) using validation loss for the evaluation objective, not by minimizing training loss. If several rounds tie for the lowest validation loss, a predeclared rule such as selecting the smallest tied round gives a reproducible choice.

Why Validation Loss Can Turn Up

For squared-error prediction, a simple decomposition explains the basic pattern. Suppose a new response at a fixed predictor value \(x\) is \(Y=f(x)+\varepsilon\), where \(E[\varepsilon\mid x]=0\) and \(\operatorname{Var}(\varepsilon\mid x)=\sigma^2\). Let \(\hat f_M(x)\) be the fitted prediction from a training sample, with randomness arising from which training sample was observed. The new response noise is assumed independent of that sample. Then expected squared prediction error is

$$ E\!\left[(Y-\hat f_M(x))^2\mid x\right] = \sigma^2+ \left(E[\hat f_M(x)]-f(x)\right)^2+ \operatorname{Var}(\hat f_M(x)). $$

To see why, write \(Y-\hat f_M=(Y-f)+(f-\hat f_M)\), square, and take expectations. The cross-product has expectation zero because the new response noise has conditional mean zero and is independent of the fitted model. The first squared term contributes \(\sigma^2\). For the second, add and subtract \(E[\hat f_M]\); its expected square is the squared difference between the average fitted prediction and \(f\), plus the variance of the fitted prediction. These are the squared bias and variance terms.

Adding rounds can reduce bias by allowing a more adaptable fit, but may increase variance by making the fitted predictions more sensitive to the training sample. The irreducible noise term does not change with \(M\). This explains why validation error may first improve and later worsen. The decomposition is an expectation over repeated training samples at a fixed \(x\); one observed validation curve is only a noisy estimate of predictive performance, not a direct measurement of each component.

Worked Examples

Worked Example: Locate a Validation-Loss Minimum

A hypothetical insurer fits a squared-error boosting model to a training set and evaluates it on four separate validation observations. The table gives prediction errors \(y-\hat y\) at four successive round counts. Use mean squared error (MSE), defined as the sum of squared errors divided by the number of observations, and select the smallest round count attaining the minimum validation MSE.

Rounds \(M\)Training errorsValidation errors
02, 2, 2, 22, 0, 0, 2
11, 1, 1, 11, 0, 0, 1
20.5, 0.5, 0.5, 0.50, 1, 1, 0
30.25, 0.25, 0.25, 0.25-1, 2, 2, -1

Method. Square each error, add within each data set, and divide by four. At \(M=0\), training MSE is \((4+4+4+4)/4=16/4=4\); validation MSE is \((4+0+0+4)/4=8/4=2\).

At \(M=1\), training MSE is \((1+1+1+1)/4=4/4=1\), and validation MSE is \((1+0+0+1)/4=2/4=0.5\). At \(M=2\), training MSE is \((0.25+0.25+0.25+0.25)/4=1/4=0.25\), and validation MSE is \((0+1+1+0)/4=2/4=0.5\).

At \(M=3\), training MSE is \((0.0625+0.0625+0.0625+0.0625)/4=0.25/4=0.0625\). Validation MSE is \((1+4+4+1)/4=10/4=2.5\). The validation minimum is 0.5, tied at \(M=1\) and \(M=2\). The stated tie rule selects \(M=1\). Training loss keeps decreasing, but validation loss rises sharply by \(M=3\), which is evidence of overfitting at that later round count.

Common mistake. Selecting \(M=3\) because it has the smallest training MSE confuses fitting the training observations with predicting new ones. The correction is to apply the stated rule to validation MSE. The arithmetic check is that every MSE is nonnegative and the validation minimum is indeed \(0.5\).

Worked Example: Distinguish Underfitting From Overfitting

For a hypothetical claim-severity model, squared-error boosting is fitted with the same learning rate and tree structure at every round count. The following losses are MSEs in thousands of dollars squared, calculated on a fixed training set and validation set. Select the candidate round count with the least validation MSE, and describe the curve.

Rounds \(M\)Training MSEValidation MSE
0120100
107060
204542
303244
402551

The minimum validation MSE among the candidates is 42, at \(M=20\), so choose 20 rounds under the stated criterion. At \(M=0\), both losses are high relative to their later values, consistent with an insufficiently fitted starting model. From 0 to 20 rounds, training MSE falls from 120 to 45, a reduction of \(120-45=75\); validation MSE falls from 100 to 42, a reduction of \(100-42=58\). Both curves improve over this part of the path.

After \(M=20\), training MSE falls from 45 to 32 and then to 25. In contrast, validation MSE rises from 42 to 44 and then to 51. The increase from round 20 to round 40 is \(51-42=9\), or \(9/42\approx0.2143\), a 21.43% increase relative to the minimum. The pattern is consistent with overfitting beyond the validation minimum; it does not imply that every individual round after 20 is necessarily worse in true predictive performance.

Common mistake. Choosing 40 because its training MSE is smallest would ignore the validation curve. Choosing 30 because the validation loss is “close” to 42 would also require an additional, specified tolerance rule; none is given here. The method is to select the minimum among the supplied candidate validation losses. Checking the table confirms that 42 is less than 44, 51, 60, and 100.

Worked Example: Compare Losses Fairly When Sample Sizes Differ

A hypothetical pricing team compares two round counts for a squared-error model. There are 100 training observations and 20 validation observations. At \(M=10\), the training sum of squared errors (SSE) is 400 and the validation SSE is 100. At \(M=20\), the training SSE is 300 and the validation SSE is 120. Calculate the per-observation losses, select the better of these rounds by validation MSE, and compare the training-validation gaps.

Method. Divide each SSE by its own sample size. At \(M=10\), training MSE is \(400/100=4\), while validation MSE is \(100/20=5\). The training-validation gap, defined here as validation MSE minus training MSE, is \(5-4=1\).

At \(M=20\), training MSE is \(300/100=3\), while validation MSE is \(120/20=6\). The gap is \(6-3=3\). Validation MSE is lower at \(M=10\) than at \(M=20\), since \(5<6\), so choose \(M=10\) from these two candidates. Training fit improves by one MSE unit, from 4 to 3, but validation fit worsens by one unit, from 5 to 6.

Common mistake. Comparing the raw SSE values across training and validation sets makes their different sample sizes matter: 400 training errors are accumulated across 100 observations, while 100 validation errors are accumulated across only 20. Dividing by the relevant sample size gives comparable per-observation losses. The final check is \(400/100=4\), \(100/20=5\), \(300/100=3\), and \(120/20=6\); the validation-based choice is therefore 10 rounds.

Practical Interpretation and Common Traps

An iteration count is meaningful only in the context of the other fitting choices. In particular, the learning rate controls how much each tree changes the current prediction. A smaller learning rate often requires more rounds to achieve a comparable level of fit, but the resulting model is not guaranteed to be identical to one fitted with a larger learning rate and fewer rounds: later trees are fitted in response to the model already built. Thus, a selected round count should be reported together with the loss, learning rate, tree settings, and validation procedure.

The minimum of an observed validation curve is an estimate, not a guarantee of the best future performance. If the curve is noisy, nearby round counts may have similar measured losses. Use a clearly stated metric and selection rule, and avoid claiming that a small difference establishes a meaningful predictive advantage. The validation set must remain separate from the observations used to fit the trees; evaluating on the training set alone cannot reveal whether adding rounds has begun to harm generalization.

  • Do not mix scales. Compare MSE with MSE, or another consistently defined loss with itself, at every round. When reporting RMSE, take the square root of MSE; because square root is increasing, the round with minimum MSE also has minimum RMSE.
  • Do not mistake rounds for depth. Round count controls how many tree contributions are added. Tree depth controls the structure available within an individual tree.
  • Do not overread one fluctuation. A small isolated rise or fall in validation loss may reflect sampling variability. Consider the curve’s overall behavior and the size of the differences.
  • Do not select from training loss alone. A steadily falling training curve can coexist with a worsening validation curve.
Key takeaway: With the other boosting choices fixed, plot or tabulate training and validation loss against rounds. High losses at low \(M\) suggest underfitting; a validation-loss minimum identifies the best candidate under the chosen criterion; and falling training loss alongside persistently rising validation loss is a warning that additional rounds are overfitting.

Check Your Understanding

Use the stated loss and selection rule in each problem. Round probabilities or percentages to four decimal places when needed.

  1. A model has validation MSEs of 18, 11, 9, and 10 at \(M=0, 5, 10,\) and 15. Training MSE decreases at each step. Which candidate round count minimizes validation MSE, and what does the change after that point suggest? (Answer: \(M=10\); the rise from 9 to 10 while training loss continues to fall suggests overfitting beyond 10 rounds.)
  2. At \(M=12\), a model has validation SSE 84 on 14 observations; at \(M=18\), it has validation SSE 108 on the same 14 observations. Calculate both validation MSEs and select the better candidate. (Answer: \(84/14=6\) and \(108/14=7.7143\); select \(M=12\).)
  3. Training MSE falls from 16 to 9 as rounds increase, while validation MSE falls from 20 to 12. Which phase of the curve does this describe, and is there evidence of overfitting yet? (Answer: Both sets improve, consistent with a useful fitting phase; these two points alone show no evidence of overfitting.)
  4. A validation set contains 25 observations. At \(M=8\), its SSE is 150; at \(M=16\), its SSE is 125. Calculate the MSEs and the percentage reduction from the first MSE to the second. (Answer: MSEs are \(150/25=6\) and \(125/25=5\); the reduction is \((6-5)/6=0.1667\), or 16.67%, so \(M=16\) is better by validation MSE.)
  5. Across tested rounds \(M=10,20,30\), validation MSE is 7, 5, and 4, while training MSE falls at each step. What can be concluded about the tested minimum, and what cannot yet be concluded? (Answer: \(M=30\) is the best tested round by validation MSE; because the validation loss is still falling at the largest tested value, the curve does not establish that the overall minimum has been reached or that later rounds will overfit.)
Clinical Biostats