Lesson 07
Gradient Boosting
Nine beginner steps on three house prices: start at 60, residuals of -10, 0 and +10, then a small learning-rate correction.
What You Will Learn
Nine steps. Three houses the whole way. Prices are in lakh rupees, so the numbers stay small. Click a step to jump.
- 1. What is Gradient Boosting?
- 2. Types of Gradient Boosting
- 3. Where is it used?
- 4. Which algorithms use it?
- 5. What problems does it face?
- 6. How the trees fix the prices
- 7. Key Takeaways
- 8. Mind Map
- 9. Quiz
1. What is Gradient Boosting?
House A sold for 50. A first, simple model says 60 for every house, because 60 is the average of 50, 60 and 70. House A is 10 too high.
Gradient boosting does not throw that guess away. It hires another small model, usually a short decision tree, and asks it to study the miss. The next tree studies whatever is still wrong after that. The final price is the first guess plus every small correction.
Four words cover the name.
| Word | On these houses |
|---|---|
| Ensemble | Several trees vote as one price |
| Weak learner | Each tree is short. Alone it would be a poor price list |
| Boosting | Tree 2 is trained after tree 1, on purpose |
| Gradient | The correction points the way that shrinks the miss. On squared error, that direction is the residual. The same small-step habit is what gradient descent uses |
A residual is actual minus predicted. House A: 50 − 60 = −10. House B: 0. House C: 70 − 60 = +10.
2. Types of Gradient Boosting
These are builds of one method, not four unrelated algorithms.
| Build | What is different | On a house table |
|---|---|---|
| GBDT | The plain sequence: average, then a tree on the miss, then another | Enough to see the idea |
| XGBoost | Same sequence, with a penalty so a tree cannot get huge, and faster splits | House prices in practice |
| LightGBM | Grows the one leaf that cuts the miss the most, which suits large tables | Thousands of sales |
| CatBoost | Treats words such as city and property type as categories without a clumsy manual encoding | Location is a name, not a number |
3. Where is it used?
The method likes rows, columns, and one target you already know.
| Job | Target |
|---|---|
| Real estate | Sale price. This lesson. |
| Banking | Will this loan default? |
| Shops | Will this customer buy? |
| Health | A recorded risk category |
| Marketing | Will this customer leave? |
| Fraud | Is this payment suspicious? |
| Search | Which result should rank higher? |
4. Which algorithms use it?
| Name | What it predicts |
|---|---|
| Gradient boosting regressor | A number, such as 61 |
| Gradient boosting classifier | A category, such as default or not |
| XGBoost | Either, with its own penalties and split search |
| LightGBM | Either, built for large tables |
| CatBoost | Either, when columns are categories |
| Histogram boosting | The same family, with columns chopped into bins so the splits stay cheap |
XGBoost, LightGBM, and CatBoost are faster, stricter builds of boosted trees. They still add the next tree to fix the current miss.
5. What problems does it face?
Too many trees, or trees that are too deep. After enough steps the model can recite A, B, and C. A new house that only resembles C still receives C's memorized correction. That is overfitting. The regularization lesson is the same worry: a fit that hugs the old rows.
A step that is too large. If each tree is allowed to add the entire residual, house C jumps from 60 to 70 in one move. On these three rows that looks perfect. On a new house the full jump is often too much.
The line is slow. Tree 3 needs the misses left by tree 2. The trees cannot all be trained at once. A large table of sales makes that wait expensive. LightGBM and histogram boosting exist mainly to shorten that wait.
One strange sale. Squared error squares the miss, so a house recorded at a wild price pulls harder than a house that is only a little off. A different loss function can care less about that one row.
6. How the trees fix the prices
Three sales:
| House | Sold for |
|---|---|
| A | 50 |
| B | 60 |
| C | 70 |
Start with the average. (50 + 60 + 70) / 3 = 60. Every house is guessed at 60.
Write the misses. Residual = sold price − guess.
| House | Sold | Guess | Residual |
|---|---|---|---|
| A | 50 | 60 | −10 |
| B | 60 | 60 | 0 |
| C | 70 | 60 | +10 |
Tree 1 is trained to predict those three numbers: −10, 0, and +10.
Add only a fraction of the tree. The learning rate here is 0.1.
new prediction = previous prediction + learning rate × tree correction
House C: 60 + 0.1 × 10 = 61
House A: 60 + 0.1 × (−10) = 59
House B: 60 + 0.1 × 0 = 60
The misses that remain are smaller, not gone.
| House | Now | Still left (sold − now) |
|---|---|---|
| A | 59 | 50 − 59 = −9 |
| B | 60 | 0 |
| C | 61 | 70 − 61 = +9 |
Tree 2 is trained on −9, 0, and +9. Same rate:
House A: 59 + 0.1 × (−9) = 58.1
House C: 61 + 0.1 × 9 = 61.9
Tree 3 does this again to whatever is still left. The guesses walk toward 50 and 70. They do not arrive in one jump.
Why the word gradient. For squared error, the direction that shrinks the miss is the residual, so the tree is simply learning residuals. For other losses, the tree learns the negative gradient of that loss instead of "sold minus guess". The update line stays the same: previous prediction, plus a small step along that direction.
How the four problems are held down.
| Problem | What you change |
|---|---|
| Memorizing A, B, and C | Short trees, and a penalty on large corrections, as in XGBoost |
| Jumping the whole residual | A small learning rate, such as 0.1 |
| Endless trees | Stop when newer trees no longer help on houses the model has not memorized |
| One wild sale | A loss that does not square every miss |
| A long wait | A faster build, such as LightGBM, on a large table |
The sequence fixes the price. The rate, the depth, the penalty, and the early stop decide how far that sequence is allowed to go.
7. Key Takeaways
- Gradient boosting is several trees used as one model.
- The trees are trained in order. Each one sees the miss that is still left.
- On these houses the first guess is 60, and the residuals are −10, 0, +10.
- With learning rate 0.1, house C moves from 60 to 61, not to 70.
- For squared error the tree target is the residual. For other losses it is the gradient of that loss.
- XGBoost, LightGBM, and CatBoost are builds of this same sequence.
- Too many deep trees can memorize the training sales.
8. Mind Map
House A steps down toward 50. House C steps up toward 70. House B stays on 60. The first move for C is still 60 + 0.1 × 10 = 61.
9. Quiz
The questions use these three houses. First guess 60, residuals −10, 0 and +10, and the one-step price 61.
Check your understanding
Gradient Boosting Quiz
What is the main idea of gradient boosting?
1 / 6