Hello! Welcome to the first lesson of our new module, "Advanced Supervised Learning: Ensemble Methods."
In the last module, you mastered the process of tuning and selecting a single, optimal model. We concluded by discussing how to justify your choice based on a trade-off between performance, interpretability, and computational cost.
But what if the best approach isn't to pick just one model, but to combine the strengths of many? This powerful idea is the foundation of ensemble learning. This lesson will introduce you to this concept and explain the two most fundamental strategies: bagging and boosting. Understanding these two methods is key to unlocking some of the most powerful and widely used algorithms in machine learning.
1. The Wisdom of the Crowd: What is Ensemble Learning?
The core idea behind ensemble learning is surprisingly intuitive: a group of "weak learners" can come together to form a single "strong learner." Think of it as seeking advice from a committee of diverse experts rather than relying on a single one. By combining multiple perspectives, you can arrive at a more robust and accurate final decision.
In machine learning, a "weak learner" is a model that performs slightly better than random guessing. It might have high bias (it underfits the data) or high variance (it overfits the data). Ensemble methods combine these weak models in a strategic way to create a powerful final model that has better predictive performance and is less prone to error.
To get a clear overview of this concept, let's start with a short video.
Ensemble (Boosting, Bagging, and Stacking) in Machine Learning: Easy Explanation for Data Scientists
This video by Emma Ding provides an excellent introduction to ensemble learning, explaining how combining models can lead to better, more robust predictions.
Please watch from 00:26 to 01:27. Focus on the core principle: how a group of weak learners can form a strong learner.
As the video explains, if one model makes an error, others can correct for it. This is how ensembles improve robustness and often lead to state-of-the-art performance. The two primary ways to build these ensembles are Bagging and Boosting.
2. Bagging: Learning in Parallel
Bagging, which stands for Bootstrap Aggregating, is an ensemble method that focuses on reducing variance. It's particularly effective for models that tend to overfit, like deep decision trees.
The process works in two main steps:
- Bootstrap: We create many different random subsets of the original training data. This is done by sampling with replacement, which means a single data point from the original dataset can appear multiple times in a given subset, while other data points might not be included at all. This technique is called bootstrapping.
- Aggregate: A separate model (or base learner) is trained independently and in parallel on each of these bootstrap samples. To get a final prediction, the results from all models are combined. For classification tasks, this is done by majority vote; for regression, the predictions are averaged.
The key idea is that by training the same algorithm on slightly different data, we create a diverse set of models. Averaging their predictions cancels out the "noise" and instability (variance) of individual models, leading to a smoother, more reliable final prediction.

The most famous algorithm based on bagging is the Random Forest, which we will implement in our next lesson. It builds hundreds or thousands of decision trees in parallel, each on a different bootstrap sample of the data.
Let's watch the next segment of the video for a visual explanation of bagging.
Ensemble (Boosting, Bagging, and Stacking) in Machine Learning: Easy Explanation for Data Scientists
This part of the video explains the bagging process, from creating bootstrap samples to aggregating the results.
Please watch from 01:27 to 03:40. Pay attention to how the models are built in parallel and how bagging affects the bias-variance trade-off.
3. Boosting: Learning from Mistakes
Boosting is an ensemble method that focuses on reducing bias. It's designed to turn a collection of weak learners into a single strong learner by training them sequentially.
The process is iterative and adaptive:
- A first, simple model (a weak learner, like a shallow decision tree) is trained on the data.
- The model's predictions are evaluated, and the data points that were misclassified are identified.
- The "weights" of these incorrectly classified data points are increased. This tells the next model in the sequence to pay more attention to these "difficult" examples.
- A second weak learner is trained on this re-weighted data, focusing on the mistakes of the first model.
- This process is repeated for a specified number of models. Each successive model learns from the errors of its predecessors.
The final prediction is a weighted combination of the predictions from all models, where better-performing models are typically given more influence.

The goal of boosting is to start with a simple, high-bias model and incrementally improve it, making it more complex and accurate with each step. Famous boosting algorithms include AdaBoost, Gradient Boosting Machines (GBM), and XGBoost.
Now, let's see how the video explains this sequential process.
Ensemble (Boosting, Bagging, and Stacking) in Machine Learning: Easy Explanation for Data Scientists
This final clip from the video details the sequential nature of boosting, where each model learns from the mistakes of the one before it.
Please watch from 03:40 to 05:44. Focus on how the models are built sequentially and how boosting affects the bias-variance trade-off.
4. Bagging vs. Boosting: A Head-to-Head Comparison
You now have a conceptual understanding of both methods. Let's solidify this by directly comparing their key characteristics. The following reading provides a concise, point-by-point breakdown.
Bagging vs Boosting: A Deep Dive into Ensemble Learning for Tree ...
The article 'Bagging vs Boosting: A Deep Dive...' provides an excellent summary of the differences. We'll focus on the section that directly compares the two methods.
Please read the section titled 'Bagging vs Boosting — Key Differences'. It's a list that starts with 'Learning Strategy' and ends with 'When to Use'. This will reinforce the concepts from the video.
To summarize the most critical distinctions in a table:
| Feature | Bagging | Boosting |
|---|---|---|
| Primary Goal | Reduce Variance (combat overfitting) | Reduce Bias (combat underfitting) |
| Model Training | Parallel (models are independent) | Sequential (each model learns from predecessors) |
| Base Learners | Strong, complex models (e.g., deep decision trees) | Weak, simple models (e.g., shallow decision trees) |
| Data Usage | Trains on random bootstrap samples | Uses the full dataset but re-weights points based on error |
| Example Algorithm | Random Forest | Gradient Boosting, XGBoost, AdaBoost |
In short:
- Use Bagging when you have a complex model that is overfitting.
- Use Boosting when you have a simple model that is underfitting.
Conclusion
In this lesson, you've been introduced to the powerful concept of ensemble learning. You now understand that by combining multiple models, we can often build a more accurate and robust predictor than any single model could achieve.
Key Takeaways:
- Ensemble learning combines multiple "weak learners" to create one "strong learner," improving overall performance.
- Bagging builds models independently and in parallel on bootstrapped data samples. Its main goal is to reduce variance and prevent overfitting.
- Boosting builds models sequentially, with each model focusing on correcting the errors of the previous ones. Its main goal is to reduce bias and improve accuracy.
- The choice between bagging and boosting depends on the problem and the characteristics of your base model (i.e., whether it suffers more from high bias or high variance).
Preview of the next lesson:
Theory is great, but the real learning happens when you apply it. In our next lesson, we will get practical and implement our first ensemble model. You'll learn how to train a Random Forest model using scikit-learn and interpret its feature importances. This will be your first step in using these advanced techniques to build high-performance models.