liveBook · Manning

Residual error

As explained in Ensemble Methods for Machine Learning

A residual is the discrepancy between an observed target and a model prediction, or the corresponding per-example loss gradient in gradient boosting.

A residual error measures the gap between a target and a model’s current prediction. Its magnitude shows how badly that example is fit; in regression, its sign also shows the direction of the mistake: positive means the prediction is too low, while negative means it is too high. Residuals turn a model’s remaining mistakes into a training signal for the next stage. section 5.2.1 section 7.3

With squared loss, the negative loss gradient is the residual itself. Gradient boosting therefore fits a weak regressor to residuals rather than directly changing example weights. Large residuals receive more attention because they represent larger gaps between predictions and labels. section 5.2.1 section 5.0

A residual-driven boosting iteration proceeds as follows:

  • Start with a current ensemble prediction, often a constant such as zero. section 5.2.2
  • Compute a residual for every training example from the current prediction and loss. section 5.2.2
  • Fit a weak regression tree to predict those residuals from the features. section 5.2.2
  • Choose a step length, then add the weighted tree to the ensemble prediction. section 5.2.2

Residuals connect gradient boosting to gradient descent: gradient descent adds a negative-gradient vector directly, while gradient boosting approximates that direction with a learned weak regressor. They also distinguish gradient boosting from AdaBoost, which emphasizes difficult examples through higher weights instead of fitting their residual values. section 5.2.1 section 5.2.2

Two-moons classification

For labels converted from 0/1 to −1/1 and initial predictions of zero, Class 1 examples begin with residual +1 and Class 0 examples with residual −1. A shallow regression tree learns this first residual pattern; later trees target what the accumulated ensemble still gets wrong. A 10-estimator implementation reports 6% test error on a noisy two-moons split. section 5.2.2

Figure 5.8 Comparing AdaBoost (left) to gradient boosting (right). Both approaches train weak estimators that improve classification performance on misclassified examples. AdaBoost uses weights, with misclassified examples being assigned higher weights. Gradient boosting uses residuals, with misclassified examples having higher residuals. The residuals are nothing but negative loss gradients.
CH05_F08_Kunapuli

Compare two ways to focus later learners: AdaBoost raises weights on misclassified examples, whereas gradient boosting supplies residuals, the negative loss gradients. section 5.2.1

Because residuals derive from the selected loss, changing the loss changes which errors receive priority. This lets gradient boosting address classification, regression, and ranking problems. Learning rate and early stopping can limit overfitting; histogram-based tree learning, sampling, and feature bundling can improve large-scale training efficiency. section 5.0 section 5.6

How Ensemble Methods for Machine Learning covers it

How deep it goes
Defines residuals, derives their squared-loss gradient relation, and walks through iterative tree fitting and step-length selection.
Examples
Uses noisy two-moons classification and linear-regression under- and overprediction diagrams to illustrate residuals.
What it assumes
Assumes familiarity with loss functions and gradient descent while defining residuals directly from predictions and labels.
What you can do after
Build it from scratch by computing residuals, fitting weak regressors, selecting step lengths, and updating an additive ensemble.
How it connects
Connects residuals to gradient boosting, gradient descent, AdaBoost, loss functions, regression trees, and Newton boosting.

Also explained in

Compare how 11 books explain residual error →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Ensemble Methods for Machine Learning. The section links point to the parts of the book it draws on.