ML0081 Gradient Boosting vs Random Forest

How do gradient-boosted decision trees work, and how do they differ from random forests?

Answer

Gradient boosting builds an additive ensemble sequentially: each new tree is fit to the negative gradient of the loss with respect to the current ensemble’s predictions (for squared error, the residuals), then added in with a small learning rate. The ensemble is a directed attack on bias; every stage shrinks whatever error remains. A random forest does the opposite: it grows many deep trees independently on bootstrap samples with random feature subsets and averages their votes, which attacks variance. So boosting uses shallow trees, a learning rate, and sequence, while bagging uses deep trees, randomness, and parallel averaging.

(1) Sequential Residual Fitting: tree m targets the current gradient (pseudo-residuals); with squared loss this is literally y minus the running prediction, and shrinkage keeps any single tree from dominating.
(2) Bias vs Variance: boosting reduces bias stage by stage but can chase noise if run long or deep; random forests reduce variance by decorrelating many overfit trees, but their bias is roughly that of one tree.
(3) Modern Refinement: Yandex showed classic gradient boosting leaks target information into its own gradients (prediction shift), and CatBoost’s ordered boosting fixes it by computing each example’s gradient from a model trained only on earlier examples in a random permutation.

Three panels: initial prediction is flat with large residuals; after adding tree one the curve follows the data and residuals shrink; after tree two the fit is close and residuals are small

Figure 1: Stage-wise fitting: each new tree targets the residuals (orange stems) left by the current ensemble, so the prediction curve (blue) bends toward the data a little at every stage.

Structurally, the two ensembles could not be more different. A random forest is embarrassingly parallel: tree one and tree one hundred do not know each other, so you can train them on separate machines and the average cancels their individual overfitting. Gradient boosting is an inherently sequential chain: tree one hundred is defined by the mistakes of the previous ninety-nine, which buys accuracy on structured tabular data but makes training serial and makes the model sensitive to label noise, because late-stage trees are explicitly trained to fit whatever is left, including the noise.

Side-by-side schematics: random forest trains deep trees in parallel on bootstrap samples and averages votes; gradient boosting trains shallow trees in a chain where each consumes the previous ensemble's residuals

Figure 2: Parallel averaging vs sequential correction: the forest’s trees are independent and deep, the boosted trees are shallow and chained through residuals, with a learning rate throttling each contribution.

Mathematical Formulation:
F_m(x) = F_{m-1}(x) + \nu\, h_m(x)
r_{i,m} = -\left[\frac{\partial\, \ell(y_i, F(x_i))}{\partial\, F(x_i)}\right]_{F = F_{m-1}}

Where:

  • F_m is the ensemble after stage m, h_m the tree added at that stage, and \nu the learning rate (shrinkage, typically 0.01-0.1).
  • r_{i,m} is the pseudo-residual for example i: the negative gradient of the loss \ell with respect to the current prediction, i.e. the direction that most reduces the loss.
  • For squared loss, r_{i,m} = y_i - F_{m-1}(x_i), the ordinary residual; other losses (logistic, absolute) change what the trees are fit to.
AspectRandom ForestGradient Boosting
TrainingIndependent trees, bootstrap samples, fully parallelSequential; each tree fits current pseudo-residuals
Tree ShapeDeep, low-bias, high-varianceShallow (depth 3-8), high-bias learners
What It ReducesVariance (averaging decorrelated trees)Bias (stage-wise error correction)
Noise RobustnessRobust; noise averages outFragile; late trees chase label noise
Known IssueAveraging cannot reduce base-tree biasTarget leakage in gradients; fixed by CatBoost ordered boosting

Login to view more content


Log in to track your progress

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *