2.3.6 · D3Tree-Based & Instance Methods

Worked examples — Bagging and bootstrap aggregating

3,977 words18 min readBack to topic

This is the worked-example lab for Bagging and bootstrap aggregating. The parent note built the two engines: the variance formula and the out-of-bag fraction . Here we push both to every corner: every value of (negative, zero, positive, the ceiling ), every size of (one model, ten, infinity), classification votes (odd and even ), small- vs. large- bootstrap, and a couple of exam traps.

Before we start, three quantities and one new symbol we will lean on constantly:


The scenario matrix

Every question bagging can ask you falls into one of these cells. The examples below are labelled by cell.

# Cell (the case class) What makes it special Example
A (independent) floor term vanishes, pure drop Ex 1
B (correlated, realistic) floor dominates Ex 2
C (degenerate: identical models) zero variance reduction Ex 3
D (limiting behaviour) variance hits its floor exactly Ex 4
E (anti-correlated) floor drops below -case, best of all Ex 4b
F Classification, odd majority vote binomial, clean majority Ex 5
G Vote with correlated errors the "jump" collapses Ex 6, 6c
H Classification, even (ties!) tie-breaking rule needed Ex 6b
I Bootstrap, small (exact) is a limit, not the truth for tiny Ex 7
J Real-world word problem translate English → the formula Ex 8
K Exam twist: "how many trees do I need?" solve the formula for Ex 9

Two figures carry the derivation. Figure s01 plots ensemble variance (vertical axis) against the number of trees (horizontal axis) with one curve per : green dips lowest, yellow falls as , blue flattens onto its dashed floor at , pink is a flat line at . Figure s02 plots ensemble accuracy (vertical) against single-voter accuracy (horizontal): the yellow "5 voters" curve arches above the dashed diagonal (single voter), the green "4 voters, ties lose" curve can dip below the diagonal, and three dots mark Ex 5, Ex 6, Ex 6b. Read each cell straight off the picture.

Figure — Bagging and bootstrap aggregating

Cells A–E: the variance formula, corner by corner


Cells F–H: classification by voting

Averaging numbers (regression) and taking a majority vote (classification) behave differently, so voting gets its own tool.

Figure — Bagging and bootstrap aggregating

Cell I: the bootstrap for small (exact, not the limit)


Cell J: a real-world word problem


Cell K: the exam twist — solve for


Recall Quick self-test across the matrix

Ex 1 gave which variance (, , )? ::: Ex 2 () gave? ::: With , bagging changes variance by how much? ::: Nothing — stays . The floor for ? ::: With feasible (), variance is? ::: — better than the independent . Why can't be as negative as you like for trees? ::: Feasibility bound . Ensemble accuracy of 5 independent voters? ::: Same 5 voters but perfectly correlated? ::: (gain lost) Ex 6c mixture () accuracy? ::: — halfway between the extremes. 4 independent voters, ties-lose? ::: — worse than one voter! Why prefer odd in majority vote? ::: No ties; a strict majority always exists. Exact OOB fraction for ? ::: , below . Fewest trees for Var with ? :::

Related roads onward: Ensemble Methods frames all of this; Boosting is the other branch (it reduces bias, unlike bagging). Hinglish version: 2.3.06 Bagging and bootstrap aggregating (Hinglish).