Tutorials › Exam SRM - Statistics for Risk Modeling › Choose Boosting Or Random Forests From Validation Evidence

Exam SRM · Predictive Learning Cases · Tutorial 912 of 926

Choose Boosting Or Random Forests From Validation Evidence

Learn to compare tree ensembles fairly using validation evidence and to distinguish useful tuning changes from misleading improvements.

Advanced 13 min read

What You'll Learn

  • Compare random forests and boosted trees while holding the prediction task and validation data fixed.
  • Calculate and interpret validation RMSE for regression predictions.
  • Explain how learning rate and boosting iteration count work together.
  • Assess tree depth and forest size without assuming that more complexity always improves validation performance.
  • Compare classification probabilities using log loss as well as threshold-based accuracy.
  • Choose a candidate cautiously when validation results are close or based on few observations.

Why Compare Ensembles on the Same Validation Data?

A random forest and a boosted-tree model can both predict nonlinear relationships, but they build their predictions differently. A forest averages many trees fitted with randomness in the data and predictor selection. Boosting adds trees in sequence, with later trees aimed at improving the current model. Neither method is automatically superior for a particular prediction task. The practical question is which fitted candidate performs better on data that were not used to fit it.

A fair comparison holds the outcome, validation observations, preprocessing, and performance measure fixed. If one candidate is evaluated on different cases, or with a different error measure, a numerical ranking may reflect the evaluation setup rather than a genuine difference in predictive performance. The validation sample should represent the population and time period to which the prediction will be applied. It must remain separate from model fitting and from choices made using the validation results.

Definition: A validation set is a set of observations reserved to compare or choose among fitted candidate models. A validation error is the value of a specified prediction-loss measure, calculated by comparing those observations' outcomes with predictions made without fitting the candidate to those observations. It estimates performance on similar future observations; it is not a guarantee of future performance.

For a numerical outcome, a common measure is root mean squared error (RMSE). If validation outcomes are \(y_1,\ldots,y_n\) and predictions are \(\hat y_1,\ldots,\hat y_n\), then

$$ \operatorname{RMSE} = \sqrt{\frac{1}{n}\sum_{i=1}^{n}(y_i-\hat y_i)^2}. $$

RMSE is expressed in the outcome's units, and a smaller value is better when squared prediction errors match the decision's cost. Squaring gives large errors more influence than small ones. For a binary outcome, a measure such as log loss assesses predicted probabilities, whereas accuracy assesses classifications after choosing a threshold. The measure should reflect the decision: accuracy alone, for example, does not show how well probabilities are calibrated or how costly a wrong prediction is.

What the Tuning Settings Change

In a random forest, the predictions from many trees are combined. For a regression task, the usual prediction is their average; for classification, the forest can average class probabilities or combine votes, depending on the implementation. Increasing the number of trees often makes the average less sensitive to the particular random trees generated. It does not necessarily improve every validation score, and it is not the main control on the complexity of each tree. Tree depth and minimum leaf size determine how finely individual trees can partition the predictor space.

Boosting constructs an additive prediction in stages. In a regression setting with squared-error loss, each new tree is fitted to the current residuals, and its contribution is scaled by a learning rate. The iteration count is the number of trees added. Learning rate and iteration count must therefore be interpreted together: a smaller learning rate makes each update smaller, and often requires more iterations to build a comparable overall fit.

$$ F_m(x)=F_{m-1}(x)+\eta h_m(x), \qquad r_{im}=y_i-F_{m-1}(x_i), $$

Here \(F_m(x)\) is the boosted prediction after \(m\) iterations, \(h_m(x)\) is the new tree's prediction, and \(\eta\) is the learning rate, usually between 0 and 1. For squared-error boosting, the residual \(r_{im}\) is the direction of correction for observation \(i\) at stage \(m\). Other loss functions use the corresponding negative loss gradient rather than ordinary residuals.

The update formula explains why a high iteration count is not, by itself, evidence of overfitting, and why a low count is not, by itself, evidence of a simpler effective fit. A small \(\eta\) can require many small steps; a larger \(\eta\) can make fewer, larger steps. Validation performance is needed to assess the resulting predictions. Tree depth also matters: shallow boosting trees make limited, relatively simple corrections, while deeper trees can represent more complex patterns and may fit idiosyncrasies in the training data.

SettingRandom forest interpretationBoosting interpretation
Number of trees or iterationsMore trees can stabilize the ensemble average; individual tree complexity is controlled separately.More iterations add more sequential corrections; validation error can eventually worsen.
Tree depthControls how detailed each constituent tree can be.Controls the complexity of each sequential correction.
Learning rateNot the usual forest tuning control.Scales each added tree; interpret it jointly with iteration count.

Worked Examples: Compare the Evidence

Worked Example: Choose a Regression Ensemble by Validation RMSE

A hypothetical insurer predicts repair cost, in thousands of dollars, for four validation claims. The observed costs are \(10,20,30,40\). A random forest predicts \(12,18,33,37\), and a boosted model predicts \(11,21,28,42\). Calculate both validation RMSEs and select the better candidate by this measure.

Method. Use the same four cases and calculate each residual as observed cost minus predicted cost. Square the residuals, average them, and take the square root.

For the forest, the residuals are \(10-12=-2\), \(20-18=2\), \(30-33=-3\), and \(40-37=3\). Their squared values are \(4,4,9,9\), whose sum is \(26\). Thus, the mean squared error is \(26/4=6.5\), and RMSE is \(\sqrt{6.5}=2.5495\) thousand dollars.

For boosting, the residuals are \(10-11=-1\), \(20-21=-1\), \(30-28=2\), and \(40-42=-2\). Their squared values are \(1,1,4,4\), whose sum is \(10\). The mean squared error is \(10/4=2.5\), and RMSE is \(\sqrt{2.5}=1.5811\) thousand dollars.

Rounded to four decimal places, the forest RMSE is \(2.5495\) and the boosted-model RMSE is \(1.5811\), both in thousands of dollars. Boosting is the preferred candidate on this validation set by RMSE. Check: each squared-error total divided by four gives the stated mean squared error, and the square roots reproduce the reported RMSEs. The common mistake avoided is comparing the sum of squared errors without accounting for the shared sample size; here that sum gives the same ranking, but it is not the RMSE and is less directly interpretable.

Worked Example: Interpret Learning Rate and Iteration Count Together

A hypothetical model predicts annualized claim costs. Four validation outcomes are \(8,10,12,14\). Three boosted candidates have learning rates and iteration counts as follows: A uses \(\eta=0.05\) and 100 iterations; B uses \(\eta=0.20\) and 25 iterations; C uses \(\eta=0.20\) and 100 iterations. Their validation predictions, in the same order as the outcomes, are A: \(7,9,11,13\); B: \(8,11,12,15\); C: \(8,12,13,17\). Their training RMSEs, calculated on the same training set, are respectively \(1.00,0.50,0.00\). Choose using validation RMSE, not training RMSE.

Method. Calculate validation RMSE candidate by candidate. Candidate A has residuals \(1,1,1,1\), squared residuals \(1,1,1,1\), mean squared error \(4/4=1\), and RMSE \(\sqrt{1}=1.0000\).

Candidate B has residuals \(0,-1,0,-1\), squared residuals \(0,1,0,1\), mean squared error \(2/4=0.5\), and RMSE \(\sqrt{0.5}=0.7071\). Candidate C has residuals \(0,-2,-1,-3\), squared residuals \(0,4,1,9\), mean squared error \(14/4=3.5\), and RMSE \(\sqrt{3.5}=1.8708\).

Candidate B has the lowest validation RMSE, \(0.7071\), so choose B among these candidates. C has perfect training fit but the worst validation score, a warning that its additional iterations did not improve prediction on the reserved cases. A and B also show why iteration counts should not be compared in isolation: the learning rates differ, so the size of each update differs. Check: the three validation squared-error totals are \(4,2,14\), which produce the stated RMSEs after division by four and square roots. The common mistake avoided is choosing the candidate with the smallest training error or assuming that more iterations must help.

Worked Example: Compare Classification Probabilities and Accuracy

A hypothetical claims-screening task has four validation outcomes, in order, \(1,1,0,0\), where 1 denotes a claim requiring review. A random forest assigns probabilities \(0.7,0.6,0.4,0.3\); boosting assigns \(0.9,0.4,0.1,0.2\). Use a threshold of 0.5 to calculate accuracy, and compare log loss. For observed binary outcome \(y_i\) and predicted probability \(p_i\), log loss is the average of \(-[y_i\ln(p_i)+(1-y_i)\ln(1-p_i)]\).

Method. At threshold 0.5, predict class 1 when \(p_i\geq0.5\), and otherwise predict 0. The forest classifications are \(1,1,0,0\), so accuracy is \(4/4=1.0000\). Boosting classifications are \(1,0,0,0\), so accuracy is \(3/4=0.7500\).

For the forest, the probabilities assigned to the outcomes that actually occurred are \(0.7,0.6,1-0.4=0.6,1-0.3=0.7\). Its log loss is \(-[\ln(0.7)+\ln(0.6)+\ln(0.6)+\ln(0.7)]/4=-\ln(0.42)/2=0.4338\), rounded to four decimals.

For boosting, the probabilities assigned to the actual outcomes are \(0.9,0.4,1-0.1=0.9,1-0.2=0.8\). Its log loss is \(-[\ln(0.9)+\ln(0.4)+\ln(0.9)+\ln(0.8)]/4=-\ln(0.2592)/4=0.3375\), rounded to four decimals. Thus the forest has higher accuracy, while boosting has lower log loss. If probability quality is the goal, boosting is preferred by log loss; if the specified decision is classification at the 0.5 threshold, the forest is preferred by accuracy. Check: each product inside the logarithm is the product of the four probabilities assigned to the observed outcomes. The common mistake avoided is treating accuracy and log loss as interchangeable measures.

Making a Defensible Choice

A validation result is evidence, not an automatic verdict. When candidates have similar validation errors, a small difference may be due to which observations happened to enter the validation set. This is especially important when the validation set is small or when a few unusually large losses dominate RMSE. Report the metric, its units when applicable, the validation sample size, and the relevant tuning settings. If the comparison is close, describe it as close rather than claiming a reliable winner from a tiny numerical gap.

Use the following sequence to make the comparison interpretable:

1
Fix the prediction task.
Use the same outcome definition, prediction horizon, cases, and preprocessing for each candidate.
2
Choose a decision-relevant metric.
For example, use RMSE when large numerical errors should be penalized strongly, or a probability score when predicted probabilities matter.
3
Record the settings.
For forests, note tree depth and number of trees. For boosting, note learning rate, iteration count, and depth.
4
Rank validation results, then qualify the conclusion.
Choose the lower-error candidate for a loss measure, while considering whether the difference is material and the validation sample informative.

A frequent exam trap is to say “boosting wins because it has more trees” or “the forest wins because it averages.” Those statements confuse a method's construction with evidence about the task. Another trap is to compare a regression metric for one candidate with a classification metric for another, or to infer that a deeper tree is better merely because it can represent more structure. The correct comparison is based on predictions from both candidates on the same reserved observations, evaluated under the same relevant measure.

Key takeaway: Select between boosting and random forests from comparable validation predictions, not from method labels or training fit. Interpret boosting's learning rate jointly with its iteration count, separate forest size from individual tree complexity, and let the decision-relevant validation metric determine the ranking.

Check Your Understanding

For each problem, use the stated validation measure and settings; do not substitute a training score.

  1. A validation set has outcomes \(4,8,12\). A forest predicts \(5,7,13\), and a boosted model predicts \(4,9,11\). Calculate both RMSEs and name the lower-RMSE model. (Answer: Forest RMSE \(=\sqrt{3/3}=1.0000\); boosted RMSE \(=\sqrt{2/3}=0.8165\); boosting is lower.)
  2. Two boosted models have the same tree depth. Model A uses learning rate \(0.05\) with 200 iterations; model B uses learning rate \(0.10\) with 100 iterations. Which model is guaranteed to have lower validation error based only on these settings? (Answer: Neither; validation predictions and a common validation metric are needed.)
  3. A forest's validation RMSE is \(3.2\) thousand dollars with 100 trees and \(3.2\) thousand dollars with 500 trees, using the same depth and validation cases. What does this comparison support, and what does it not establish? (Answer: The measured validation RMSE is unchanged at the reported precision; it does not establish that 500 trees improve predictive accuracy or that the models are identical.)
  4. On four binary validation cases, the observed outcomes are \(1,0,1,0\). Candidate A assigns probabilities \(0.8,0.2,0.8,0.2\); candidate B assigns \(0.6,0.1,0.6,0.1\). Both use threshold 0.5. Which has greater accuracy, and which has lower log loss? (Answer: Both have accuracy \(4/4=1.0000\); A has lower log loss, \(-\ln(0.8^4)/4=0.2231\), versus B's \(-\ln(0.6^2\cdot0.9^2)/4=0.3081\).)
Clinical Biostats