Bagging vs Boosting in Machine Learning
Last Updated :
03 Apr, 2025
As we know, Ensemble learning helps improve machine learning results by combining several models. This approach allows the production of better predictive performance compared to a single model. Basic idea is to learn a set of classifiers (experts) and to allow them to vote. Bagging and Boosting are two types of Ensemble Learning. These two decrease the variance of a single estimate as they combine several estimates from different models. So the result may be a model with higher stability. Let's understand these two terms in a glimpse.
- Bagging: It is a homogeneous weak learners’ model that learns from each other independently in parallel and combines them for determining the model average.
- Boosting: It is also a homogeneous weak learners’ model but works differently from Bagging. In this model, learners learn sequentially and adaptively to improve model predictions of a learning algorithm.
Let’s look at both of them in detail and understand the Difference between Bagging and Boosting.
Bagging
Bootstrap Aggregating, also known as bagging, is a machine learning ensemble meta-algorithm designed to improve the stability and accuracy of machine learning algorithms used in statistical classification and regression. It decreases the variance and helps to avoid overfitting. It is usually applied to decision tree methods. Bagging is a special case of the model averaging approach.
Description of the Technique
Suppose a set D of d tuples, at each iteration i, a training set Di of d tuples is selected via row sampling with a replacement method (i.e., there can be repetitive elements from different d tuples) from D (i.e., bootstrap). Then a classifier model Mi is learned for each training set D < i. Each classifier Mi returns its class prediction. The bagged classifier M* counts the votes and assigns the class with the most votes to X (unknown sample).
Implementation Steps of Bagging
- Step 1: Multiple subsets are created from the original data set with equal tuples, selecting observations with replacement.
- Step 2: A base model is created on each of these subsets.
- Step 3: Each model is learned in parallel with each training set and independent of each other.
- Step 4: The final predictions are determined by combining the predictions from all the models.
An illustration for the concept of bootstrap aggregating (Bagging)Example of Bagging
The Random Forest model uses Bagging, where decision tree models with higher variance are present. It makes random feature selection to grow trees. Several random trees make a Random Forest.
To read more refer to this article: Bagging classifier
Boosting
Boosting is an ensemble modeling technique designed to create a strong classifier by combining multiple weak classifiers. The process involves building models sequentially, where each new model aims to correct the errors made by the previous ones.
- Initially, a model is built using the training data.
- Subsequent models are then trained to address the mistakes of their predecessors.
- boosting assigns weights to the data points in the original dataset.
- Higher weights: Instances that were misclassified by the previous model receive higher weights.
- Lower weights: Instances that were correctly classified receive lower weights.
- Training on weighted data: The subsequent model learns from the weighted dataset, focusing its attention on harder-to-learn examples (those with higher weights).
- This iterative process continues until:
- The entire training dataset is accurately predicted, or
- A predefined maximum number of models is reached.
Boosting Algorithms
There are several boosting algorithms. The original ones, proposed by Robert Schapire and Yoav Freund were not adaptive and could not take full advantage of the weak learners. Schapire and Freund then developed AdaBoost, an adaptive boosting algorithm that won the prestigious Gödel Prize. AdaBoost was the first really successful boosting algorithm developed for the purpose of binary classification. AdaBoost is short for Adaptive Boosting and is a very popular boosting technique that combines multiple “weak classifiers” into a single “strong classifier”.
Algorithm:
- Initialise the dataset and assign equal weight to each of the data point.
- Provide this as input to the model and identify the wrongly classified data points.
- Increase the weight of the wrongly classified data points and decrease the weights of correctly classified data points. And then normalize the weights of all data points.
- if (got required results)
Goto step 5
else
Goto step 2 - End
An illustration presenting the intuition behind the boosting algorithm, consisting of the parallel learners and weighted dataset.To read more refer to this article: Boosting and AdaBoost in ML
Similarities Between Bagging and Boosting
Bagging and Boosting, both being the commonly used methods, have a universal similarity of being classified as ensemble methods. Here we will explain the similarities between them.
- Both are ensemble methods to get N learners from 1 learner.
- Both generate several training data sets by random sampling.
- In Bagging, the final decision is made by averaging predictions or majority voting. In Boosting, new models focus on correcting previous errors, and the final decision is made by a weighted majority vote.
- Both are good at reducing variance and provide higher stability.
Differences Between Bagging and Boosting
S.NO | Bagging | Boosting |
|---|
| 1. | The simplest way of combining predictions that belong to the same type. | A way of combining predictions that belong to the different types. |
|---|
| 2. | Aim to decrease variance, not bias. | Aim to decrease bias, not variance. |
|---|
| 3. | Each model receives equal weight. | Models are weighted according to their performance. |
|---|
| 4. | Each model is built independently. | New models are influenced by the performance of previously built models. |
|---|
| 5. | Different training data subsets are selected using row sampling with replacement and random sampling methods from the entire training dataset. | Iteratively train models, with each new model focusing on correcting the errors (misclassifications or high residuals) of the previous models |
|---|
| 6. | Bagging tries to solve the over-fitting problem. | Boosting tries to reduce bias. |
|---|
| 7. | If the classifier is unstable (high variance), then apply bagging. | If the classifier is stable and simple (high bias) the apply boosting. |
|---|
| 8. | In this base classifiers are trained parallelly. | In this base classifiers are trained sequentially. |
|---|
| 9 | Example: The Random forest model uses Bagging. | Example: The AdaBoost uses Boosting techniques |
|---|
Similar Reads
CatBoost in Machine Learning
When working with machine learning, we often deal with datasets that include categorical data. We use techniques like One-Hot Encoding or Label Encoding to convert these categorical features into numerical values. However One-Hot Encoding can lead to sparse matrix and cause overfitting. This is wher
6 min read
Boosting in Machine Learning | Boosting and AdaBoost
Boosting is an ensemble learning technique that sequentially combines multiple weak classifiers to create a strong classifier. It is done by training a model using training data and is then evaluated. Next model is built on that which tries to correct the errors present in the first model. This proc
4 min read
Machine Learning - Learning VS Designing
In this article, we will learn about Learning and Designing and what are the main differences between them. In Machine learning, the term learning refers to any process by which a system improves performance by using experience and past data. It is kind of an iterative process and every time the sys
3 min read
SVM vs KNN in Machine Learning
Support Vector Machine(SVM) and K Nearest Neighbours(KNN) both are very popular supervised machine learning algorithms used for classification and regression purpose. Both SVM and KNN play an important role in Supervised Learning.Table of Content Support Vector Machine(SVM)K Nearest Neighbour(KNN)Su
4 min read
Rule Engine vs Machine Learning?
Answer: Rule engines use predefined logic to make decisions, while machine learning algorithms learn from data to make predictions or decisions.Rule engines and machine learning represent two fundamentally different approaches to decision-making and prediction in computer systems. While rule engines
2 min read
Decision Tree in Machine Learning
A decision tree is a supervised learning algorithm used for both classification and regression tasks. It has a hierarchical tree structure which consists of a root node, branches, internal nodes and leaf nodes. It It works like a flowchart help to make decisions step by step where: Internal nodes re
9 min read
KNN vs Decision Tree in Machine Learning
There are numerous machine learning algorithms available, each with its strengths and weaknesses depending on the scenario. Factors such as the size of the training data, the need for accuracy or interpretability, training time, linearity assumptions, the number of features, and whether the problem
5 min read
Random Forest Algorithm in Machine Learning
Random Forest is a machine learning algorithm that uses many decision trees to make better predictions. Each tree looks at different random parts of the data and their results are combined by voting for classification or averaging for regression. This helps in improving accuracy and reducing errors.
5 min read
Evaluation Metrics in Machine Learning
Evaluation is always good in any field, right? In the case of machine learning, it is best practice. In this post, we will cover almost all the popular as well as common metrics used for machine learning.Table of ContentClassification MetricsAccuracyLogarithmic Loss Area Under Curve (AUC)PrecisionRe
7 min read
Design a Learning System in Machine Learning
According to Arthur Samuel âMachine Learning enables a Machine to Automatically learn from Data, Improve performance from an Experience and predict things without explicitly programmed.â In Simple Words, When we fed the Training Data to Machine Learning Algorithm, this algorithm will produce a mathe
5 min read