Gradient boosting (XGBoost, LightGBM)

Supervised · Classification & regression Gradient boosting also uses many small decision trees, but builds them one after another. Each new tree focuses on the mistakes the previous trees still make, and its correction is added to the running prediction. Popular versions include XGBoost, LightGBM and CatBoost.

Everyday analogy

A student who, after each mock test, studies only the questions they got wrong. Test by test, the remaining mistakes shrink.

Example

Used for: credit scoring, sales and demand forecasting, insurance pricing, ranking search results. It's a favourite for spreadsheet-style data and data science competitions.

Remaining errorAfter tree 1100After tree 260After tree 335After tree 1015After tree 1005
Each new tree corrects the leftover mistakes of the trees before it, so the error keeps shrinking.

Each tree adds a correction

StartAverage delivery time: 30 min
+
Tree 1It's raining: +8 min
+
Tree 2Peak dinner hour: +5 min
+
Tree 3Long distance: +4 min
=
Prediction47 minutes

How it works, step by step

  1. Start with a very simple prediction, such as the average of all past values.
  2. Calculate the error for every example: actual value minus prediction.
  3. Train a small tree to predict those errors.
  4. Add a small part of that tree's correction to the prediction. This step size is called the learning rate.
  5. Repeat hundreds of times, each tree fixing what is still wrong.

Worked example

A food app predicts delivery time. The average is 30 minutes. Tree 1 learns that rain adds about 8 minutes, tree 2 that dinner peak adds 5, tree 3 that long distances add 4. For a long-distance order on a rainy evening at peak time: 30 + 8 + 5 + 4 = 47 minutes.

✓ Good for

  • Often the most accurate choice for tables and spreadsheet data
  • Handles mixed numbers and categories
  • Fast, well-tested libraries are freely available

⚠ Watch out for

  • Needs careful tuning (number of trees, learning rate, depth)
  • Can overfit if it runs too long
  • Harder to explain than a single tree

Try it yourself

About 10 min

Correct the mistakes step by step

  1. Guess a friend's monthly spending.
  2. Hear the real number, then adjust your guess with a rule (e.g. add 20% for weekends).
  3. Repeat with another rule and note how the error shrinks.

What you should see: Each new step fixes the leftover error of the previous ones, like boosting.

Use any free AI chatbot (ChatGPT, Claude, Gemini or Copilot). Never paste private or confidential information.

Build it for real · guided projectYour first machine learning model: predict house pricesAbout 75 min · Copy-paste code · step by step
Test what you learned

Take a quick quiz, or look up any word in the glossary.