Bagging (bootstrap aggregating) grows each tree in a random forest on its own bootstrap sample: N draws made with replacement from the N original training rows. Because sampling is with replacement, some rows get drawn multiple times and others are never drawn at all — those left-out rows are that tree's out-of-bag (OOB) set.
P(a given row is never drawn in N draws) = (1 − 1/N)^N
→ e^−1 ≈ 36.8% as N → ∞
draw-count per row ~ Binomial(N, 1/N) → Poisson(1)
The left matrix is the training set itself — one cell per row, brightening each time it is drawn this tree. The top-right chart is a scrolling time series of the cumulative OOB average versus trees grown, converging on the dashed theory line. The bottom-right histogram counts how many rows were drawn 0, 1, 2, 3+ times this tree, overlaid against the Poisson(1) limit that bootstrap draw-counts approach as N grows.
- Grow One Tree — runs one bootstrap draw of N samples, animated draw by draw; matrix cells light up as they're picked.
- Auto-Grow Forest — repeats tree after tree; the chart's cumulative average is a Monte-Carlo estimate that converges on (1−1/N)^N by the law of large numbers.
- Drag the chart left/right to scroll through tree history once more trees have grown than fit the window; the window-size slider changes how many trees are visible at once.
- Why it matters — because roughly a third of the data is OOB for every tree, a random forest can score each tree only on the rows it never trained on, giving an internal, honest estimate of generalization error with no separate validation split needed.