Simple Algorithm
Machine Learning · Descent · 22 min

Boosting

Turning weak learners into a strong one by focusing on mistakes.

A decision stump, one yes-or-no question about one feature, is often barely better than a coin flip. Train a second stump on data reweighted toward the first one's mistakes, then a third, and let them vote: the committee's training error falls exponentially fast. This lesson derives AdaBoost, proves that bound, and shows that the algorithm is greedy minimization of the exponential loss.

What you’ll learn

  • Run AdaBoost by hand, with labels y∈{−1,+1}y\in\{-1,+1\}: the weighted error εt\varepsilon_t, the vote αt=12ln⁡1−εtεt\alpha_t=\tfrac12\ln\frac{1-\varepsilon_t}{\varepsilon_t} and the multiplicative reweighting.
  • Prove that AdaBoost's training error is at most ∏t2εt(1−εt)≤exp⁡(−2∑tγt2)\prod_t2\sqrt{\varepsilon_t(1-\varepsilon_t)}\le\exp\big(-2\sum_t\gamma_t^2\big), where γt=12−εt\gamma_t=\tfrac12-\varepsilon_t.
  • Derive AdaBoost as forward stagewise additive modeling with the exponential loss, and identify what its score estimates.
  • Contrast boosting with bagging, and explain why label noise hurts AdaBoost.

Weak learners and the boosting question

Boosting answers a question that sounds too good to be true. Suppose an algorithm can only ever produce rules slightly better than a coin flip. Can you combine its outputs into a classifier that is almost always right?

Work with two classes labeled y∈{−1,+1}y\in\{-1,+1\} and a training set D={(xi,yi)}i=1n\data=\{(\mathbf x_i,y_i)\}_{i=1}^n. Give each example a weight D(i)≥0D(i)\ge0 with ∑iD(i)=1\sum_iD(i)=1. A weak learner is an algorithm that, for every such weighting, returns a classifier hh whose weighted error ∑iD(i) 1[h(xi)≠yi]\sum_iD(i)\,\mathbf 1[h(\mathbf x_i)\ne y_i] is at most 12−γ\tfrac12-\gamma, for some fixed edge γ>0\gamma>0. The usual choice is the decision stump, a decision tree with a single split: h(x)=+1h(\mathbf x)=+1 if xj>cx_j>c and −1-1 otherwise, or the reverse. Finding the best stump takes one pass over each sorted feature.

Kearns and Valiant were the first to ask whether weak learnability implies strong learnability, meaning arbitrarily small error. Schapire found the first provable boosting algorithm in 1989 (published in 1990), and Freund a much more efficient one a year later, but both were awkward in practice. AdaBoost (Freund & Schapire, 1995; journal version 1997) removed the difficulties, and it is adaptive: it never needs to know γ\gamma. Like bagging, boosting builds an ensemble of trees, but the two work in opposite ways.

PropertyBaggingBoosting
How members are trainedindependently, in parallel, on bootstrap samplesone after another, each on data reweighted toward earlier mistakes
Typical memberdeep trees: low bias, high variancestumps or small trees: high bias, low variance
Combinationplain average or majority voteweighted vote sign⁡(∑tαtht(x))\sign\big(\sum_t\alpha_th_t(\mathbf x)\big)
Mainly reducesvariancebias, and often variance too
Adding membersthe test error levels offtraining error keeps falling, so the number of rounds is tuned
Label noisefairly robustsensitive: weight piles up on mislabeled points
The two classic ways to build an ensemble of trees. The rest of this lesson makes the boosting column precise.
Check your understanding

Which of these is exactly what boosting's weak-learning assumption asks for?

  1. A stump that reaches 51% accuracy when all training points are weighted equally
  2. A deep tree that always reaches zero training error
  3. An algorithm that, for every weighting of the training set, returns a classifier with weighted error at most 0.45
  4. A classifier with 30% error on the test set
Show the answer

C. An algorithm that, for every weighting of the training set, returns a classifier with weighted error at most 0.45

Boosting will hand the weak learner many different weightings, concentrated on whatever is currently hard, so the guarantee must hold for all of them. Edge γ=0.05\gamma=0.05 for every weighting is enough: the training-error bound in this lesson then drives the error to zero.

AdaBoost, step by step

AdaBoost keeps a weight on every training example. Each round it asks the weak learner for a classifier on the current weights, scores it, and shifts weight toward the examples that classifier got wrong:

text
ADABOOST(examples (x_1, y_1) ... (x_n, y_n) with y_i in {-1, +1}, rounds T)
  D_1(i) = 1/n for every i                       # uniform weights
  for t = 1..T:
      h_t     = WeakLearner(examples, weights D_t)
      eps_t   = sum_i D_t(i) * [h_t(x_i) != y_i]   # weighted error, needs eps_t < 1/2
      alpha_t = 0.5 * ln((1 - eps_t) / eps_t)      # the vote: large when eps_t is small
      for every i:
          D_{t+1}(i) = D_t(i) * exp(-alpha_t * y_i * h_t(x_i)) / Z_t
          # a mistake is multiplied by e^{alpha_t}, a hit by e^{-alpha_t};
          # Z_t rescales the new weights to sum to 1
  return H(x) = sign( sum_t alpha_t * h_t(x) )

The update needs no case split: yiht(xi)=+1y_ih_t(\mathbf x_i)=+1 on a hit and −1-1 on a mistake. A stump with εt=12\varepsilon_t=\tfrac12 gets αt=0\alpha_t=0, no vote at all. One with εt>12\varepsilon_t>\tfrac12 would get αt<0\alpha_t<0, which simply flips its predictions.

Predict before you look

On 100 equally weighted points, the first stump misclassifies 10 of them, so ε1=0.1\varepsilon_1=0.1. After the update, what percentage of the total weight sits on those 10 points?

Show the answer

50 %

α1=12ln⁡9=ln⁡3\alpha_1=\tfrac12\ln9=\ln3, so each mistake's weight is multiplied by 3 and each hit's by 13\tfrac13: the mistakes carry 10×0.03=0.310\times0.03=0.3, the hits 90×0.01/3=0.390\times0.01/3=0.3, and Z1=0.6=20.1⋅0.9Z_1=0.6=2\sqrt{0.1\cdot0.9}. After rescaling, each misclassified point weighs 0.050.05, five times its old weight, and together they carry exactly half.

Think first The last answer was no accident: under the new weights Dt+1D_{t+1}, the classifier hth_t always has weighted error exactly 12\tfrac12. Why, and why is that useful?

After the update the mistakes weigh εteαt/Zt=εt(1−εt)/Zt\varepsilon_te^{\alpha_t}/Z_t=\sqrt{\varepsilon_t(1-\varepsilon_t)}/Z_t and the hits (1−εt)e−αt/Zt=εt(1−εt)/Zt(1-\varepsilon_t)e^{-\alpha_t}/Z_t=\sqrt{\varepsilon_t(1-\varepsilon_t)}/Z_t: the same amount, so each side holds half. The next round therefore gains nothing by returning hth_t again. It must find a rule that beats chance on the new weights, half of which sit on the examples hth_t got wrong, which is how AdaBoost manufactures diverse members.

Why the training error falls exponentially

DerivationProof
  1. DT+1(i)=e−yiF(xi)n∏t=1TZt⟹∏t=1TZt=1n∑i=1ne−yiF(xi)D_{T+1}(i)=\frac{e^{-y_iF(\mathbf x_i)}}{n\prod_{t=1}^TZ_t}\quad\Longrightarrow\quad\prod_{t=1}^TZ_t=\frac1n\sum_{i=1}^ne^{-y_iF(\mathbf x_i)}

    Multiply the TT updates together. Every weight starts at 1/n1/n and has been multiplied by e−αtyiht(xi)/Zte^{-\alpha_ty_ih_t(\mathbf x_i)}/Z_t each round. Since the final weights sum to 1:

  2. 1n∑i=1n1[H(xi)≠yi] ≤ 1n∑i=1ne−yiF(xi) = ∏t=1TZt\frac1n\sum_{i=1}^n\mathbf 1\big[H(\mathbf x_i)\ne y_i\big]\ \le\ \frac1n\sum_{i=1}^ne^{-y_iF(\mathbf x_i)}\ =\ \prod_{t=1}^TZ_t

    A mistake (or a tie) means yiF(xi)≤0y_iF(\mathbf x_i)\le0, where e−yiF(xi)≥1e^{-y_iF(\mathbf x_i)}\ge1. So the exponential dominates the 0–1 loss term by term:

  3. Zt=(1−εt)e−αt+εteαt,αt=12ln⁡1−εtεt ⟹ Zt=2εt(1−εt)Z_t=(1-\varepsilon_t)e^{-\alpha_t}+\varepsilon_te^{\alpha_t},\qquad\alpha_t=\frac12\ln\frac{1-\varepsilon_t}{\varepsilon_t}\ \Longrightarrow\ Z_t=2\sqrt{\varepsilon_t(1-\varepsilon_t)}

    Each normalizer splits into hits and mistakes. It is convex in α\alpha and smallest where (1−εt)e−α=εteα(1-\varepsilon_t)e^{-\alpha}=\varepsilon_te^{\alpha}, which is exactly AdaBoost's choice of αt\alpha_t:

  4. 2(12−γt)(12+γt)=1−4γt2≤e−2γt22\sqrt{\big(\tfrac12-\gamma_t\big)\big(\tfrac12+\gamma_t\big)}=\sqrt{1-4\gamma_t^2}\le e^{-2\gamma_t^2}

    Write εt=12−γt\varepsilon_t=\tfrac12-\gamma_t, then use 1+x≤ex1+x\le e^x with x=−4γt2x=-4\gamma_t^2 and take square roots:

Three consequences. First, AdaBoost's αt\alpha_t is precisely the choice that greedily minimizes the bound ∏tZt\prod_tZ_t: the algorithm is built around this proof. Second, the training error is a multiple of 1/n1/n, so once the bound drops below 1/n1/n the error must be exactly zero. Third, nothing requires knowing γ\gamma in advance; whatever edges the weak learner delivers are used. In practice the edges shrink as the weights concentrate on hard examples, so later rounds make slower progress.

The circles simulation shows the bound as its "error bound" readout: 0.40 after 10 rounds, 0.13 after 50 and 0.019 after 200. It always sits above the training error, which is already 0 at round 50: the bound is a guarantee, not a forecast.

Predict before you look

Every stump has edge at least γ=0.1\gamma=0.1 (weighted error at most 0.4) on n=1,000n=1{,}000 training points. After how many rounds does the bound e−2γ2Te^{-2\gamma^2T} guarantee zero training error?

Show the answer

346 rounds

Zero error is guaranteed once e−2γ2T<1/ne^{-2\gamma^2T}<1/n, that is T>ln⁡n/(2γ2)=6.908/0.02≈345.4T>\ln n/(2\gamma^2)=6.908/0.02\approx345.4, so 346 rounds; the tighter product ∏t1−4γt2\prod_t\sqrt{1-4\gamma_t^2} already gets there at 339. The rate depends on γ2\gamma^2: an edge of 0.05 would need four times as many rounds.

The statistical view: stagewise fitting of the exponential loss

Friedman, Hastie & Tibshirani (2000) recast boosting in statistical terms. An additive model F(x)=∑mβmbm(x)F(\mathbf x)=\sum_m\beta_mb_m(\mathbf x) can be fitted by forward stagewise additive modeling: add one term at a time, choosing it to reduce the loss as much as possible, and never revisit earlier terms. With the exponential loss ℓ(y,F)=e−yF\ell(y,F)=e^{-yF}, this recipe reproduces AdaBoost exactly.

DerivationStagewise exponential loss is AdaBoost
  1. ∑i=1ne−yi(Fm−1(xi)+βh(xi))=∑i=1nwi(m)e−βyih(xi),wi(m)=e−yiFm−1(xi)\sum_{i=1}^ne^{-y_i(F_{m-1}(\mathbf x_i)+\beta h(\mathbf x_i))}=\sum_{i=1}^nw_i^{(m)}e^{-\beta y_ih(\mathbf x_i)},\qquad w_i^{(m)}=e^{-y_iF_{m-1}(\mathbf x_i)}

    Stage mm adds βh\beta h to the current fit Fm−1F_{m-1}. The past enters only through fixed weights, which are AdaBoost's weights before normalization:

  2. =e−β∑iwi(m)+(eβ−e−β)∑iwi(m) 1[h(xi)≠yi]=e^{-\beta}\sum_iw_i^{(m)}+\big(e^{\beta}-e^{-\beta}\big)\sum_iw_i^{(m)}\,\mathbf 1\big[h(\mathbf x_i)\ne y_i\big]

    Split the sum into hits (yih=1y_ih=1) and mistakes (yih=−1y_ih=-1) and regroup:

  3. hm=arg min⁡h∑iwi(m)1[h(xi)≠yi],βm=12ln⁡1−errmerrmh_m=\argmin_h\sum_iw_i^{(m)}\mathbf 1\big[h(\mathbf x_i)\ne y_i\big],\qquad\beta_m=\frac12\ln\frac{1-\mathrm{err}_m}{\mathrm{err}_m}

    For any β>0\beta>0 the best hh minimizes the weighted error, which is the weak learner's job. With errm\mathrm{err}_m its normalized weighted error, minimizing (1−errm)e−β+errmeβ(1-\mathrm{err}_m)e^{-\beta}+\mathrm{err}_me^{\beta} over β\beta gives AdaBoost's vote:

  4. Fm=Fm−1+βmhm,wi(m+1)=wi(m)e−βmyihm(xi)F_m=F_{m-1}+\beta_mh_m,\qquad w_i^{(m+1)}=w_i^{(m)}e^{-\beta_my_ih_m(\mathbf x_i)}

    The new fit and the next weights follow, and they match AdaBoost's update up to normalization:

What does the score FF estimate? Minimize the expected loss at each x\mathbf x, with p(x)=P(y=+1∣x)p(\mathbf x)=P(y=+1\mid\mathbf x):

E[e−yF(x)∣x]=p(x)e−F(x)+(1−p(x))eF(x)⟹F∗(x)=12ln⁡p(x)1−p(x)\E\big[e^{-yF(\mathbf x)}\mid\mathbf x\big]=p(\mathbf x)e^{-F(\mathbf x)}+\big(1-p(\mathbf x)\big)e^{F(\mathbf x)}\quad\Longrightarrow\quad F^*(\mathbf x)=\frac12\ln\frac{p(\mathbf x)}{1-p(\mathbf x)}
Half the log-odds. Its sign is the Bayes classifier, and in principle p(x)=1/(1+e−2F(x))p(\mathbf x)=1/(1+e^{-2F(\mathbf x)}) turns the score into a probability. Logistic regression estimates the full log-odds; written on AdaBoost's scale, its loss becomes the binomial deviance ln⁡(1+e−2yF)\ln(1+e^{-2yF}), which has the same minimizer as the exponential loss.
LossAs a function of the margin m=yFm=yFFor a badly misclassified point (m→−∞m\to-\infty)
0–11[m≤0]\mathbf 1[m\le0]constant: every mistake costs 1
Exponential (AdaBoost)e−me^{-m}grows exponentially
Binomial deviance (LogitBoost)ln⁡(1+e−2m)\ln\big(1+e^{-2m}\big)grows linearly
Hinge (SVM)max⁡(0,1−m)\max(0,1-m)grows linearly
Squared(1−m)2=(y−F)2(1-m)^2=(y-F)^2grows quadratically, and also penalizes confident correct answers (m>1m>1)
Convex surrogates for the 0–1 loss (Soft Margins & Surrogate Losses compares them in depth). The exponential loss and the binomial deviance agree to second order at m=0m=0, both ≈const−m+m2/2\approx\text{const}-m+m^2/2, and they have the same population minimizer, but they treat badly misclassified points very differently.
Check your understanding

A training point is mislabeled, so the ensemble's margin on it, yiF(xi)y_iF(\mathbf x_i), keeps getting more negative. Under which loss does that point's pull on the next fit, the size of the loss gradient, grow fastest?

  1. The hinge loss
  2. The binomial deviance
  3. The 0–1 loss
  4. The exponential loss
Show the answer

D. The exponential loss

The gradient of e−me^{-m} is −e−m-e^{-m}, which grows without bound as m→−∞m\to-\infty. AdaBoost's weights are exactly these normalized gradients, so a few persistently misclassified points can dominate the weighted data that later stumps are fitted to.

Bias, variance and label noise

Bagging averages deep, low-bias trees and attacks their variance (Bagging & Random Forests). Boosting starts from high-bias stumps and builds an increasingly expressive additive model, so it attacks bias. Breiman had argued that voting methods work mainly by reducing variance, but Schapire, Freund, Bartlett & Lee (1998) found a counterexample in his own test problems: on "ringnorm", boosting stumps cut the error from 40.6% to 12.2% while the variance, under two common definitions for classification, did not fall at all. Boosting does more than reduce variance.

The price of chasing the hardest examples is sensitivity to label noise. A mislabeled point is one the ensemble should get wrong, so its margin keeps falling and its weight keeps growing.

python
from sklearn.ensemble import AdaBoostClassifier
from sklearn.tree import DecisionTreeClassifier

stump = DecisionTreeClassifier(max_depth=1)
model = AdaBoostClassifier(estimator=stump, n_estimators=500, learning_rate=0.5)
model.fit(X_train, y_train)

# accuracy on held-out data after every round: choose the number of rounds there
val_scores = list(model.staged_score(X_val, y_val))
best_rounds = 1 + max(range(len(val_scores)), key=val_scores.__getitem__)

learning_rate multiplies every vote αt\alpha_t, a form of shrinkage. staged_score evaluates the ensemble after each round, so choosing the number of rounds on a validation set costs a single fit.

Key takeaways

  • AdaBoost (labels ±1\pm1) reweights the training points each round, multiplying mistakes by eαte^{\alpha_t} and hits by e−αte^{-\alpha_t}, and combines its members by the weighted vote sign⁡∑tαtht\sign\sum_t\alpha_th_t with αt=12ln⁡1−εtεt\alpha_t=\tfrac12\ln\frac{1-\varepsilon_t}{\varepsilon_t}.
  • Its training error is at most ∏t2εt(1−εt)≤exp⁡(−2∑tγt2)\prod_t2\sqrt{\varepsilon_t(1-\varepsilon_t)}\le\exp(-2\sum_t\gamma_t^2): any constant edge γ\gamma gives zero training error once T>ln⁡n/(2γ2)T>\ln n/(2\gamma^2).
  • AdaBoost is forward stagewise additive modeling with the exponential loss e−yFe^{-yF}, and its score estimates half the log-odds.
  • Bagging mainly reduces variance; boosting reduces bias, and often variance as well.
  • The exponential loss lets mislabeled points accumulate weight, so AdaBoost is sensitive to label noise; early stopping and gentler losses help.

Check yourself

In the interactive lesson these are scored with your confidence, and what you miss comes back for review.

Question 1

In round tt, the best stump on the current weights has weighted error exactly εt=0.5\varepsilon_t=0.5. What happens?

  1. Its vote is αt=0\alpha_t=0: it changes neither HH nor the weights, so boosting makes no further progress
  2. It gets vote αt=0.5\alpha_t=0.5, half the usual weight
  3. AdaBoost flips its predictions and gives it a large positive vote
  4. The weights of all points are reset to uniform
Show the answer

A. Its vote is αt=0\alpha_t=0: it changes neither HH nor the weights, so boosting makes no further progress

αt=12ln⁡(0.5/0.5)=0\alpha_t=\tfrac12\ln(0.5/0.5)=0, so the stump adds nothing to FF, and e±0=1e^{\pm0}=1 leaves every weight unchanged (Zt=1Z_t=1). The weak learner faces the same weights again: the weak-learning assumption has failed, and the Convergence lesson AdaBoost & the Exponential Loss shows what that says about the data.

Question 2

Every stump has edge at least γ=0.05\gamma=0.05. Roughly how many rounds does the bound need to guarantee a training error below 1%?

  1. About 46
  2. About 92
  3. About 920
  4. About 9,200
Show the answer

C. About 920

Solve e−2γ2T≤0.01e^{-2\gamma^2T}\le0.01: T≥ln⁡100/(2⋅0.052)=4.605/0.005≈921T\ge\ln100/(2\cdot0.05^2)=4.605/0.005\approx921. The number of rounds grows like 1/γ21/\gamma^2, so weaker learners cost quadratically more.

Question 3

In the population limit, which quantity does AdaBoost's score F(x)=∑tαtht(x)F(\mathbf x)=\sum_t\alpha_th_t(\mathbf x) estimate?

  1. The probability P(y=1∣x)P(y=1\mid\mathbf x)
  2. The log-odds ln⁡P(y=1∣x)P(y=−1∣x)\ln\frac{P(y=1\mid\mathbf x)}{P(y=-1\mid\mathbf x)}
  3. Half the log-odds, 12ln⁡P(y=1∣x)P(y=−1∣x)\tfrac12\ln\frac{P(y=1\mid\mathbf x)}{P(y=-1\mid\mathbf x)}
  4. The margin of the Bayes classifier
Show the answer

C. Half the log-odds, 12ln⁡P(y=1∣x)P(y=−1∣x)\tfrac12\ln\frac{P(y=1\mid\mathbf x)}{P(y=-1\mid\mathbf x)}

Minimizing pe−F+(1−p)eFpe^{-F}+(1-p)e^{F} over FF gives e2F=p/(1−p)e^{2F}=p/(1-p), so F∗=12ln⁡p1−pF^*=\tfrac12\ln\frac p{1-p}, and P(y=1∣x)=1/(1+e−2F∗(x))P(y=1\mid\mathbf x)=1/(1+e^{-2F^*(\mathbf x)}). Its sign is the Bayes classifier's prediction.

Question 4

You flip 10% of the training labels at random and run AdaBoost for many rounds. What should you expect?

  1. Nothing changes, because the training-error bound still holds
  2. AdaBoost detects the flipped points and gives them less and less weight
  3. The bound becomes exp⁡(+2∑tγt2)\exp\big(+2\sum_t\gamma_t^2\big), so training error grows
  4. Weight concentrates on the flipped points, later stumps bend to fit them, and test error suffers unless you stop early
Show the answer

D. Weight concentrates on the flipped points, later stumps bend to fit them, and test error suffers unless you stop early

A flipped point disagrees with the pattern the ensemble learns, so its margin yiF(xi)y_iF(\mathbf x_i) stays negative and its weight ∝e−yiF(xi)\propto e^{-y_iF(\mathbf x_i)} keeps growing, until later stumps bend to fit it. Fitting those points is fitting noise. Early stopping, shrinkage and gentler losses limit the damage.

Question 5

Why is boosting usually run with small trees, while bagging uses deep ones?

  1. Small trees are faster to fit, and that is the only reason
  2. Averaging cuts variance, which deep trees have plenty of; boosting builds an expressive model out of high-bias pieces, and a tree that fits the weighted data perfectly leaves it nothing to correct
  3. Small trees are strong learners and deep trees are weak learners
  4. Bagging cannot be applied to stumps
Show the answer

B. Averaging cuts variance, which deep trees have plenty of; boosting builds an expressive model out of high-bias pieces, and a tree that fits the weighted data perfectly leaves it nothing to correct

Each method attacks a different error term. Bagging leaves bias alone and reduces variance, so it needs low-bias members. Boosting adds members that correct the current fit, reducing bias step by step, and stays in control because each member is simple.

Go deeper

Further reading

  • Y. Freund & R. E. Schapire, "A decision-theoretic generalization of on-line learning and an application to boosting," Journal of Computer and System Sciences 55(1), 119–139 (1997).
  • J. Friedman, T. Hastie & R. Tibshirani, "Additive logistic regression: a statistical view of boosting," Annals of Statistics 28(2), 337–407 (2000).
  • T. Hastie, R. Tibshirani & J. Friedman, The Elements of Statistical Learning, 2nd ed. (Springer, 2009), chapter 10.
  • R. E. Schapire & Y. Freund, Boosting: Foundations and Algorithms (MIT Press, 2012).