04.11 Lesson 11 of 16
1 hBoosting for Tabular Data
Understand gradient boosting as a stage-wise additive model and tune its capacity and learning rate carefully.
By the end of this lesson
You will be able to
- Distinguish bagging from boosting.
- Explain additive learners and residual or gradient correction.
- Describe learning rate, estimator count and tree depth.
- Recognize overfitting and early-stopping signals.
Boosting builds an additive sequence
Bagging trains many models independently and averages them. Boosting adds learners sequentially: each new learner is trained to improve the current ensemble, often by following the negative gradient of a chosen loss. In gradient boosting, a model starts with a simple prediction and adds shallow trees that correct remaining errors. The learning rate scales each contribution, while the number of estimators controls how many additions are made.
from sklearn.ensemble import GradientBoostingClassifier
boosted = GradientBoostingClassifier(
n_estimators=150,
learning_rate=0.05,
max_depth=2,
random_state=42,
) Learning rate and tree depth control the fit
A smaller learning rate usually requires more trees but makes each update more conservative. Deeper trees can capture complex interactions but may overfit. Tune learning_rate, n_estimators, max_depth and leaf-size controls together using a suitable validation strategy. Histogram-based gradient boosting can be more efficient on larger datasets. Libraries such as XGBoost, LightGBM and CatBoost extend the family with different engineering and regularization choices; this module focuses on the algorithmic idea rather than one library-specific API.
Apply what you learned
ExerciseCompare bagging with boosting
Compare a random forest and a gradient-boosted tree model using the same split, preprocessing and scoring metric.
- Choose a classification dataset and create a fixed training/validation split.
- Fit a random forest and a gradient-boosting classifier.
- Compare training and validation metrics and training time.
- Change the boosted model's learning rate while adjusting estimator count.
- Explain when you would prefer bagging or boosting.
The comparison uses held-out data, records settings and describes independent aggregation versus sequential error correction.
Free references
Study resources
- 01 Gradient Boost Part 1: Regression Main Ideas Video
Watch the individual first part for the additive boosting idea. Use the documentation for classifier-specific details.
- 02 Ensemble Methods Article
Read the Gradient Boosting section and compare the sequential process with Random Forests.
Check your understanding
Self-test
-
Question 1
What is the key difference between bagging and boosting?
Bagging trains diverse learners independently and aggregates them; boosting adds learners sequentially so later learners improve the current ensemble. -
Question 2
What does the learning rate control in gradient boosting?
It scales each new learner's contribution to the ensemble. Smaller values make updates more conservative.
Completion check
Move on when
You can describe additive boosting, identify its main capacity controls and compare it fairly with a random forest.