Skip to main content
L1.16

Boosting: Learning From Previous Errors

About 24 min

Goal

By the end of this lesson, you can explain gradient boosting as a sequence of small learners that correct remaining error, and contrast that process with the diversified-tree aggregation used by Random Forest.

Random Forest and boosting solve the one-tree problem differently​

Random Forest says: train many deliberately different trees, then aggregate their predictions.

Boosting says: start with a simple prediction, inspect what is still wrong, then add another weak learner that improves the remaining error.

The final model is a sum of many small corrections.

Build intuition with residuals​

Suppose a first model predicts 10 when the true value is 14. The residual is:

14 - 10 = 4

Now suppose the next small tree predicts a correction of +4 for this kind of example. With boosting learning rate 0.3, we add only 30% of that correction:

added correction = 0.3 × 4 = 1.2
new prediction = 10 + 1.2 = 11.2
new residual = 14 - 11.2 = 2.8

A later learner then works on the errors that remain. If its suggested correction for this example were +2, the same learning rate would add 0.6, moving the prediction to 11.8.

Real gradient boosting fits small trees across all training examples at each stage, so one example will not necessarily improve monotonically at every step. The important training-level question is whether the ensemble's overall objective is improving.

For classification the mathematics differs, but the same beginner intuition holds: each stage is trained to improve the current ensemble's remaining error under its objective.

Weak learners make controlled corrections​

Gradient boosting commonly uses small decision trees as individual learners.

A shallow tree may be weak by itself, but a sequence of small trees can build a flexible model.

The learning rate controls how strongly each new tree's correction is added. A smaller rate usually means each stage contributes less and more stages may be needed.

This is related to, but not identical to, the learning rate in L1.6 — Gradient Descent and Learning Rate. In L1.6, the learning rate scales a parameter update computed from a gradient. Here, the boosting learning rate scales how much of a newly fitted learner's prediction is added to the ensemble.

Watch error shrink stage by stage​

  1. Click Run with n_estimators = 4 and learning_rate = 0.3.
  2. Read stage MSE:. It should decrease across the four stages.
  3. Read first-example residuals:. Notice that this one residual falls, then briefly rises, then falls again. Overall MSE can improve even when one example temporarily gets worse.
  4. Find n_estimators = 4. Change only 4 to 6.
  5. Before running, predict that training MSE will continue to decrease as two more correction stages are added. Click Run and inspect the longer stage MSE: list.
  6. Press Reset. Find learning_rate = 0.3 and change only 0.3 to 0.15.
  7. Predict that each stage will make a smaller contribution, then click Run and compare how quickly MSE changes across the first four stages.
  8. Press Reset afterward.

Python used here: iterating through staged predictions and collecting list results (P1 — loops).

Loading lab…

More stages can eventually overfit, so falling training error is not enough to choose the final model. Validation evidence still matters.

Also, “later learners focus on remaining error” is an ensemble-level statement. It does not mean every individual row's absolute residual must shrink after every stage.

The contrast to remember​

Random ForestGradient Boosting
Trees are diversified with row and feature randomnessTrees are added sequentially
Trees do not primarily exist to correct the previous treeEach new learner targets remaining error
Predictions are aggregated across treesPredictions are built as staged corrections
Diversity is centralError correction is central

Both are tree ensembles, but their training logic is different.

Practical descendants​

XGBoost, LightGBM, and CatBoost are important practical gradient-boosting systems with additional engineering and modeling features.

At this level, do not memorize library-specific knobs. First understand the shared idea: sequentially add weak learners that reduce the current model's errors.

Quick Check

1. What does a later boosting learner focus on?
2. What is the central contrast with Random Forest?
3. Why is lower training error after more boosting stages not sufficient evidence?

0 of 3 questions answered.

Key Takeaways

  • Gradient boosting builds a model as a sequence of small corrections.
  • Later learners focus on errors left by the current ensemble.
  • Random Forest relies on diverse trees plus aggregation instead.
  • Boosting learning rate scales each learner's contribution; gradient-descent learning rate scales a parameter update.
  • Overall training loss can fall even while one example's residual temporarily grows.
  • More stages can reduce training error and still hurt generalization.

Next Lesson

Next, you will leave supervised prediction briefly and learn how K-means and PCA search for structure when no target label is provided.

References

Lesson actions

Completion is stored locally on this device.

View progress