Ensemble Learning: Bagging vs. Boosting
Ensemble methods combine multiple weak models into one strong one, like a committee outperforming a single expert. Bagging reduces variance; Boosting reduces bias. The footgun: Boosting can overfit noisy data by trying to model the noise itself.
WHY IT EXISTS A single machine learning model is often a compromise. It might be too simple and miss patterns (high bias), or too complex and memorize noise (high variance). Ensemble methods were created to systematically manage this bias-variance tradeoff by combining multiple models to produce one superior result.
THE MENTAL MODEL Think of it as the wisdom of the crowds for models. Instead of relying on one expert who might have blind spots, you form a committee. Bagging is a democratic committee where diverse, independent experts vote. Boosting is a team of specialists built sequentially, where each new member is trained specifically to fix the mistakes of the team so far.
HOW IT WORKS Bagging (Bootstrap Aggregating) attacks high variance. It works by creating many random subsets of the training data, training an independent model on each, and then averaging their predictions (for regression) or taking a majority vote (for classification). The errors of the individual models tend to cancel each other out, resulting in a more stable, less overfit final model.
Boosting attacks high bias. It works by training models sequentially. The first model is trained on the data, then the algorithm identifies its errors. The next model is trained to pay more attention to those specific errors. This process repeats, with each new model focusing on the mistakes of the ensemble that came before it. The final prediction is a weighted sum of all the models.
WHEN TO USE IT Use Bagging (like Random Forest) when your base model is overfitting. It's great for reducing variance and is easy to parallelize since the models are trained independently. Use Boosting (like XGBoost or LightGBM) when your base model is underfitting. It's excellent for reducing bias and often achieves top-tier performance, though it requires more careful tuning.
WHEN NOT TO USE IT Avoid Boosting on very noisy datasets. Its core mission is to correct errors, so it will diligently try to fit the noise, leading to severe overfitting. Bagging provides less benefit if your base model is already stable and has low variance. Boosting is also harder to parallelize than Bagging because of its sequential nature.
ONE CANONICAL EXAMPLE Random Forest is the canonical example of Bagging, creating an ensemble of many decision trees trained on different subsets of data and features. XGBoost (eXtreme Gradient Boosting) is a famous implementation of Boosting that sequentially builds trees to correct the errors of the prior ones, known for its performance in data science competitions.
Read the original → en.wikipedia.org
Get five bites like this every day.
Tezvyn delivers a daily feed of 60-second tech bites with quizzes to lock in what you learn.