Ensemble Methods I
Majority voting, the binomial error formula, bagging, random forests, boosting, AdaBoost.
Contains the exact formula for the ε = 0.4 ensemble question (slide 12) and the worked reference value (slide 13).
What an ensemble is
> A combination of multiple individual models that achieves better generalisation performance than the individual ones.
The framing: after collecting predictions from 10 experts, combining them strategically is more accurate and more robust than trusting any one.

The simplest combination rule:
- Construct multiple classifiers
- Collect their predictions on the test instance
- Take the final classification by majority voting
The goal is stated as: take any simple weak classifier and transform it into a strong one, without requiring any fancy new algorithms.

Three voting variants appear on one slide: same prediction by all the models (unanimous), by at least 50% (majority), and by the highest number (plurality — the only one that generalises to more than two classes).

Why it works — the two conditions
Ensembling is more accurate than any individual classifier if the base classifiers are:
- Accurate — better than random guessing
- Diverse — they make different errors on new examples
Diversity is the non-obvious one: if all members make the same mistakes, averaging changes nothing.

The error formula — memorise this
Assume $n$ independent base classifiers, each with error probability $\varepsilon$, and a majority vote that fails when at least $k$ of them are wrong. Then
$$\boxed{\;\varepsilon_{\text{ensemble}} = P(y \ge k) = \sum_{k}^{n}\binom{n}{k}\,\varepsilon^{k}\,(1-\varepsilon)^{\,n-k}\;}$$
with
- $n$ — number of base classifiers
- $k$ — number of misclassifications needed to fail the majority vote, i.e. $k = \lfloor n/2\rfloor + 1$
- $\varepsilon$ — error probability of a single base classifier

The reference value printed on the deck:
$$n = 11,\;\; \varepsilon = 0.25 \;\Longrightarrow\; \varepsilon_{\text{ensemble}} = 0.034$$
Note what that says: eleven independent 75%-accurate classifiers, majority-voted, are 96.6% accurate. The improvement comes from independence, not from any individual being good.
The independence assumption is the whole trick, and real ensembles violate it. Base classifiers trained on the same data are positively correlated, so the binomial formula underestimates the ensemble error. If asked "why does this bound not hold exactly in practice?", that is the answer — and it is why bagging deliberately injects randomness (bootstrap samples) and random forests add feature subsampling: both exist to decorrelate the members so the binomial argument becomes closer to true.
How the members are trained — the taxonomy
| Strategy | Training | Members combined by | Method |
|---|---|---|---|
| Bagging | parallel, different training sets | voting / averaging | random forest |
| Boosting | sequential, re-weighting samples | weighted vote | AdaBoost |
| Mixture of experts | parallel, objective encouraging division of labour | input-dependent gate | MoE |

That one table is the backbone of the entire ensemble section. Everything else is detail on one row.
Voting with probabilities
Class prediction from predicted class probabilities, with optional weights:
$$\hat y = \arg\max_{j}\;\sum_{i=1}^{n} w_i\, p_{i,j}$$
where $p_{i,j}$ is classifier $i$'s probability for class $j$, and $w_i = 1/n$ for uniform weighting.

Worked example from the deck — three classifiers, weights $w=[0.2,0.2,0.6]$:
$$h_1(x)\to[0.9,\,0.1],\quad h_2(x)\to[0.8,\,0.2],\quad h_3(x)\to[0.4,\,0.6]$$
$$p(j{=}0\mid x) = 0.2(0.9)+0.2(0.8)+0.6(0.4) = 0.58$$ $$p(j{=}1\mid x) = 0.2(0.1)+0.2(0.2)+0.6(0.6) = 0.42$$
Final prediction: class 0. Notice that $h_3$ alone would have said class 1 — the weighted vote overrides it because $h_3$ carries 60% of the weight but the other two agree.
Bagging — Bootstrap AGGregatING
> Similar to majority voting, but uses the same learning algorithm on different subsets of the training data, drawn as bootstrap samples.

Bootstrap sampling is the same "random sampling with replacement, train set size equal to the original dataset size" as in the validation deck.
The mechanism is variance reduction: averaging $n$ identically-distributed but correlated predictors with pairwise correlation $\rho$ gives
$$\operatorname{Var}(\text{average}) = \rho\sigma^2 + \frac{1-\rho}{n}\sigma^2$$
As $n\to\infty$ the second term vanishes but the first does not — so bagging can only remove the uncorrelated part. Lowering $\rho$ is therefore the lever, which is precisely what random forests do.
Random forests
> A special type of bagging algorithm: a collection of decision trees, which also draws a random subset of features at each split, and aggregates their results.

Two sources of randomness, and this is the answer to "how is a random forest different from bagging decision trees?": bootstrap rows and a random feature subset per split (typically $\sqrt{d}$ features for classification). The feature subsampling decorrelates the trees, lowering $\rho$ in the formula above, which is what makes the ensemble actually better than one tree rather than merely smoother.
Boosting
> The ensemble consists of very simple base classifiers — weak learners, only slightly better than random guessing (a decision tree stump). Each subsequent learner focuses on the training samples the previous ones got wrong.
Key difference from bagging: boosting uses random subsets without replacement.

The generic boosting steps
- Draw a random subset $D_1$ without replacement from $D$ → train weak learner $C_1$
- Draw a second subset $D_2$ without replacement and add 50% of the previously misclassified samples → train $C_2$
- Find the samples $D_3$ on which $C_1$ and $C_2$ disagree → train $C_3$
- Combine $C_1, C_2, C_3$ by (weighted) majority voting

AdaBoost — Adaptive Boosting
$$\text{Input } x\in\mathbb{R}^d, \qquad \text{Output } y \in \{-1,+1\}$$
Let $w_n^m$ be the weight on training sample $n$ for classifier $m$.
Cost function (weighted error count):
$$J_m = \sum_{n=1}^{N} w_n^m \cdot \mathbb{1}\!\left[\,y_m(x^{(n)}) \neq t^{(n)}\right]$$
Weighted error rate:
$$\epsilon_m = \frac{J_m}{\sum_n w_n^m}$$
Classifier quality — how much say it gets in the final vote:
$$\boxed{\;\alpha_m = \ln\!\left(\frac{1-\epsilon_m}{\epsilon_m}\right)\;}$$
Re-weighting for the next round:
$$w_n^{m+1} = w_n^{m} \exp\!\left(-\frac{1}{2}\,t^{(n)}\alpha_m\,y_m(x^{(n)})\right)$$

Read those four formulas for what they say:
- $\alpha_m > 0$ only when $\epsilon_m < 0.5$; a classifier worse than chance gets a negative weight, i.e. its vote is inverted.
- A perfect classifier ($\epsilon_m \to 0$) gets $\alpha_m \to \infty$.
- A chance classifier ($\epsilon_m = 0.5$) gets $\alpha_m = 0$ — it is ignored.
- In the exponential, the product $t^{(n)} y_m(x^{(n)})$ is $+1$ when the prediction is correct and $-1$ when wrong. So correct samples get multiplied by $e^{-\alpha/2} < 1$ (down-weighted) and wrong ones by $e^{+\alpha/2} > 1$ (up-weighted). That is the "focus on hard examples" mechanism in one line.
Prediction — weighted vote of all $M$ classifiers:
$$H(x) = \operatorname{sign}\!\left(\sum_{m=1}^{M}\alpha_m\, y_m(x)\right)$$

"Write the key steps in boosting to make ensemble predictions." Answer with the AdaBoost loop: (1) initialise all sample weights uniformly $w_n^0 = 1/N$; (2) for $m = 1..M$: fit weak learner $y_m$ on the weighted data, compute its weighted error $\epsilon_m$, compute its vote weight $\alpha_m = \ln((1-\epsilon_m)/\epsilon_m)$, then re-weight each sample by $\exp(-\tfrac12 t^{(n)}\alpha_m y_m(x^{(n)}))$ and renormalise so the weights sum to 1; (3) predict with $H(x)=\operatorname{sign}(\sum_m \alpha_m y_m(x))$. Emphasise that training is sequential (each learner depends on the previous weights) and that this is exactly what distinguishes boosting from bagging's parallel independent fits.
The mapping to remember
| Bagging | Boosting | |
|---|---|---|
| Training | parallel, independent | sequential, dependent |
| Data per member | bootstrap samples with replacement | subsets without replacement, re-weighted |
| Member strength | strong, low-bias learners (deep trees) | weak learners (stumps) |
| Primary effect | reduces variance | reduces bias |
| Failure mode | little gain if members are correlated | can overfit if run too long / noisy labels |
| Example | random forest | AdaBoost |





















