Classical ML

Bagging vs Boosting

Contrasting parallel variance reduction in Bagging against sequential bias reduction in Boosting.

🟡 intermediate5 min readensemblesmust-know
Bagging and Boosting are the two dominant ensemble learning paradigms in machine learning. Bagging (Bootstrap Aggregating) trains independent complex base models in parallel on random data subsets to reduce variance (Random Forest). Boosting trains simple weak base models sequentially, focusing each new model on errors made by previous models to reduce bias (AdaBoost, XGBoost).

The Two Ensemble Paradigms

Ensemble methods combine multiple machine learning models to build a single predictor that outperforms any individual base model.

The two main ways to build ensembles are Bagging and Boosting:

  BAGGING (Parallel Variance Reduction):
  Data ──► Bootstrap Sample 1 ──► [ Deep Tree 1 ] ──┐
  Data ──► Bootstrap Sample 2 ──► [ Deep Tree 2 ] ──┼──► AVERAGE PREDICTIONS (Parallel!)
  Data ──► Bootstrap Sample 3 ──► [ Deep Tree 3 ] ──┘

  BOOSTING (Sequential Bias Reduction):
  Data ──► [ Shallow Tree 1 ] ──► Compute Residual Errors ──► [ Shallow Tree 2 ] ──► Compute Residuals ...
                                                                                   (Sequential!)

Detailed Architectural Comparison

┌──────────────────────────┬──────────────────────────┐
│ BAGGING (Bootstrap Agg.) │ BOOSTING (Gradient/Ada)  │
├──────────────────────────┼──────────────────────────┤
│ Base Models: Deep Trees  │ Base Models: Shallow     │
│ (High Variance, Low Bias)│ Stumps (High Bias, Low V)│
│ Built: PARALLEL.         │ Built: SEQUENTIAL.       │
│ Main Goal: Reduce Var.   │ Main Goal: Reduce Bias.  │
│ Overfitting Risk: Low.   │ Overfitting Risk: High.  │
└──────────────────────────┴──────────────────────────┘

1. Bagging (Bootstrap Aggregating)

$$\text{Ensemble Variance} = \rho \sigma^2 + \frac{1 - \rho}{B} \sigma^2$$

As $B \to \infty$, variance shrinks down to $\rho \sigma^2$. Decorrelating models (lowering $\rho$) via Random Forest feature subspacing cuts total variance dramatically.

2. Boosting (Sequential Error Correction)

$$F(x) = \sum_{k=1}^B \gamma_k h_k(x)$$

Summary Matrix

MetricBagging (Random Forest)Boosting (XGBoost, LightGBM)
Training ExecutionFully Parallel ($O(1)$ time on CPU/GPU)Sequential ($O(B)$ sequential steps)
Base Learner TypeDeep unpruned treesShallow trees (max_depth 3 to 6)
Error Component FixedVarianceBias
Sensitivity to OutliersLowHigh (Focuses heavily on hard samples)
Hyperparameter SensitivityLow (Works out of the box)High (Requires careful learning rate tuning)

Say this out loud

Bagging trains complex deep trees in parallel on random bootstrap samples to reduce model variance, making Random Forest fast and robust against overfitting. Boosting trains simple shallow trees sequentially, focusing each new tree on residual errors from previous steps to reduce model bias, producing state of the art tabular accuracy in XGBoost.

Followups to expect

  1. What is Stacking (Stacked Generalization)? An ensemble method where diverse base models (e.g. SVM, Random Forest, Neural Net) train on raw features, and a meta model (e.g. Logistic Regression) trains on the predictions of base models.
  2. Why does Boosting overfit if given too many trees? Because Boosting sequentially fits errors, adding thousands of trees will eventually force the ensemble to fit noise in individual training samples.

Check yourself

Question 1 of 3

What primary component of error (Bias or Variance) does Bagging reduce compared to Boosting?

More in Classical ML

See all →
Bias–Variance Tradeoff4 minOverfitting vs Underfitting3 minLinear Regression4 min