๐Ÿ“ˆ Machine Learning ยท Lecture 20 of 47

Boosting I: AdaBoost and the Power of Weak Learners

Can many weak rules of thumb combine into a strong classifier? AdaBoost answered yes. We walk through the reweighting algorithm, derive it as exponential-loss minimisation, and discuss its margins and sensitivity to noise.

In 1988 Michael Kearns asked a theoretical question: if we can learn classifiers that are only slightly better than random guessing โ€” weak learners โ€” can we combine them into an arbitrarily accurate strong learner? Robert Schapire proved the answer is yes, and in 1995 Yoav Freund and Schapire created AdaBoost (Adaptive Boosting), a practical algorithm that won them the Gรถdel Prize. AdaBoost with decision stumps powered the Violaโ€“Jones face detector that ran in early digital cameras.

Boosting versus bagging#

  • Bagging trains models independently in parallel on resampled data and averages them โ€” reducing variance.
  • Boosting trains models sequentially, each focusing on the mistakes of the ensemble so far โ€” reducing bias (and often variance too).

The AdaBoost algorithm#

Binary labels $y_i \in \{-1, +1\}$. Start with uniform example weights $w_i = 1/n$. For $t = 1, \dots, T$:

  1. Train a weak learner $h_t$ on the weighted data (typically a decision stump โ€” a one-split tree).
  2. Compute its weighted error:
$$ \epsilon_t = \sum_{i:\, h_t(\mathbf{x}_i) \ne y_i} w_i $$
  1. Compute its vote weight:
$$ \alpha_t = \frac{1}{2}\ln\frac{1 - \epsilon_t}{\epsilon_t} $$
  1. Update and renormalise example weights:
$$ w_i \leftarrow \frac{w_i\,\exp\big(-\alpha_t\,y_i\,h_t(\mathbf{x}_i)\big)}{Z_t} $$

Final classifier:

$$ H(\mathbf{x}) = \text{sign}\left(\sum_{t=1}^{T}\alpha_t\,h_t(\mathbf{x})\right) $$

Reading the update: misclassified examples ($y_ih_t(\mathbf{x}_i) = -1$) are multiplied by $e^{\alpha_t} > 1$ โ€” they become more important; correctly classified examples are down-weighted. The next weak learner is forced to concentrate on the hard cases. Learners with low error receive large votes $\alpha_t$; a learner at chance ($\epsilon_t = 0.5$) receives $\alpha_t = 0$.

Training error falls exponentially#

If each weak learner has edge $\gamma_t = 0.5 - \epsilon_t > 0$, the training error of $H$ is bounded by

$$ \prod_t 2\sqrt{\epsilon_t(1 - \epsilon_t)} \le \exp\left(-2\sum_{t=1}^{T}\gamma_t^2\right) $$

Even a small consistent edge drives training error to zero exponentially fast. This is the theoretical heart of boosting.

AdaBoost as exponential-loss minimisation#

Friedman, Hastie and Tibshirani (2000) showed that AdaBoost performs forward stagewise additive modelling with the exponential loss:

$$ L(y, F(\mathbf{x})) = e^{-yF(\mathbf{x})}, \qquad F(\mathbf{x}) = \sum_t\alpha_t h_t(\mathbf{x}) $$

At each step it greedily adds the term $\alpha_th_t$ that most reduces this loss; the formula for $\alpha_t$ is exactly the optimal step size. This statistical view opened the door to gradient boosting, which works with any differentiable loss (next lecture).

The quantity $yF(\mathbf{x})$ is the margin. The exponential loss keeps pushing margins larger even after all training points are correctly classified โ€” which helps explain AdaBoost's often surprising resistance to overfitting as $T$ grows.

Implementation from scratch#

python
import numpy as np
from sklearn.tree import DecisionTreeClassifier
from sklearn.datasets import make_classification
from sklearn.model_selection import train_test_split

X, y01 = make_classification(n_samples=1500, n_features=10, n_informative=5, random_state=1)
y = 2 * y01 - 1                                        # labels in {-1, +1}
X_tr, X_te, y_tr, y_te = train_test_split(X, y, test_size=0.3, random_state=0)

def adaboost(X, y, T=200):
    n = len(y); w = np.full(n, 1 / n)
    learners, alphas = [], []
    for t in range(T):
        stump = DecisionTreeClassifier(max_depth=1).fit(X, y, sample_weight=w)
        pred = stump.predict(X)
        eps = np.clip(w[pred != y].sum(), 1e-10, 1 - 1e-10)
        alpha = 0.5 * np.log((1 - eps) / eps)
        w *= np.exp(-alpha * y * pred); w /= w.sum()
        learners.append(stump); alphas.append(alpha)
    return learners, np.array(alphas)

def predict(learners, alphas, X, upto=None):
    F = sum(a * h.predict(X) for h, a in zip(learners[:upto], alphas[:upto]))
    return np.sign(F)

L, A = adaboost(X_tr, y_tr)
for T in [1, 10, 50, 200]:
    print(f"T={T:>3}: train acc {np.mean(predict(L, A, X_tr, T) == y_tr):.3f}  "
          f"test acc {np.mean(predict(L, A, X_te, T) == y_te):.3f}")

A single stump is weak; two hundred of them form a strong classifier.

Weaknesses#

  • Sequential training cannot be parallelised across rounds.
  • Performance depends on weak learners being better than chance but not too complex.

Variants#

  • SAMME โ€” multiclass AdaBoost (used by scikit-learn).
  • Real AdaBoost โ€” uses class probability estimates.
  • LogitBoost โ€” minimises logistic loss; more robust to noise.
  • Gradient boosting โ€” the general framework (next lecture).
JA
Written by

Janin A Apurba

B.Sc. in CSE, AUST ยท Advanced ICT Officer, CNRS-UNHCR. Teaching AI, ML and Deep Learning to the next generation of engineers and researchers.

Keep learning

Related lectures

๐Ÿ“ˆ Machine Learning

Random Forests: Decorrelated Trees and Robust Predictions

Random forests add feature randomness to bagged trees, breaking their correlation. We explain the algorithm, its hyperparameters, OOB estimates, feature importance pitfalls and when forests are the right tool.

Intermediateโฑ 5 min#068
๐Ÿ“ˆ Machine Learning

Boosting II: Gradient Boosting Machines

Gradient boosting performs gradient descent in function space, fitting each new tree to the negative gradient of the loss. We derive the algorithm, explain shrinkage and subsampling, and tune it properly.

Advancedโฑ 5 min#070
๐Ÿ“ˆ Machine Learning

Bagging and the Bootstrap: Variance Reduction by Averaging

Averaging many noisy models trained on resampled data produces one stable model. We study the bootstrap, derive why bagging reduces variance, and use out-of-bag error as a free validation estimate.

Intermediateโฑ 5 min#067