Chapter 7. Ensembles and boosting
Data Mining as Observation, draft 0.3, 2026-09-09. Week 7 of ECE 514. Reading due before this chapter is ESL 15 and ESL 10.1 [2], then ESL 10.9 to 10.13 and the boosted-trees introduction in the XGBoost documentation. TSK 4.10 is the gentler alternative. Every number below traces to a committed file listed in the last section.
This chapter is standard content with one sidebar, and the book says so rather than stretch. Ensembles are the black-box arm of chapter 6's question, do you need one or would a formula suffice, and the standard texts cover bagging, random forests, and gradient boosting completely. What the book adds is three things it has already earned. The reader of a gradient is the optimizer, and its read operator is the loss curvature, which chapter 4's flip was measured against and bounded by. The question of when an ensemble wins has a measured answer on the author's own benchmark, and the answer is that it is a property of the dataset. And the sidebar, which is the reason the chapter exists in this book, states how to compare a method to an ensemble fairly, using the five analyses that tried to rescue the author's own comparison and could not.
The project preregistration is due Wednesday of this week. Section 7.6 says what it must contain, and chapter 8 says why.
7.1 Bagging reduces variance, boosting reduces bias
A single tree is a high-variance reader. Small changes to the training rows move its splits and its predictions. Bagging fits many trees on bootstrap resamples of the rows and averages them [26], and the variance of the average depends on how correlated the trees are.
$$\operatorname{Var}\Big(\frac1B\sum_{b=1}^{B}\hat f_b\Big)=\rho\,\sigma^{2}+\frac{1-\rho}{B}\,\sigma^{2}, \tag{7.1}$$
where each tree has variance sigma squared and any two trees have correlation rho. Averaging removes the second term and not the first, which is why a random forest decorrelates its trees by subsampling features. ESL 15 has the rest, out-of-bag estimation and the importances, and the book adds only that out-of-bag scoring is a harness with its own read subspace, and that impurity importance is the right sensitivity for a tree while permutation importance is a finite difference at the scale of a column, which inherits chapter 2's warning when features are correlated.
Boosting is sequential [27]. Each new model is fit to the mistakes of the ensemble so far, and the ensemble is a weighted sum.
$$F_M(x)=\sum_{m=1}^{M}\nu\,h_m(x),\qquad \alpha_m=\tfrac12\ln\frac{1-\varepsilon_m}{\varepsilon_m}\ \ \text{for AdaBoost}, \tag{7.2}$$
That an average's squared error is at most the mean squared error of its members, and that boosting's step size is positive exactly when the weak scorer beats chance and its reweighting makes the last scorer's weighted error one half, are machine-checked in Lean in appendix C.
where a learner no better than chance, at error one half, gets weight zero. ESL 10.1 and TSK 4.10 have the algorithms and the bias-variance framing, that bagging helps a high-variance learner and boosting a high-bias one, and the book does not repeat them.
7.2 Gradient boosting reads the loss through its curvature
Gradient boosting generalizes the sequential picture [28, 29]. At each step the current ensemble's predictions are held fixed, the negative gradient of the loss with respect to those predictions is computed per row, and a tree is fit to that gradient. The tree's leaves are then assigned values that take a step down the loss. The second-order form, which the modern libraries use, sets each leaf's value from the sum of gradients and the sum of curvatures of the rows in the leaf.
$$w_j^{\star}=-\frac{G_j}{H_j+\lambda},\qquad G_j=\sum_{i\in j}\frac{\partial\ell_i}{\partial F},\qquad H_j=\sum_{i\in j}\frac{\partial^{2}\ell_i}{\partial F^{2}}. \tag{7.3}$$
For logistic loss the curvature of each row is its predicted probability times one minus that probability, so rows the model is sure about contribute little curvature and rows near the boundary contribute most. The regularization constant lambda is a budget. It shrinks every leaf toward zero in proportion to how little curvature supports it.
The book's reading of equation 7.3 is chapter 1's consumer table, in which the optimizer reads its update against the loss curvature and discards the flat directions. The reader of a gradient is the optimizer, its read operator is the Hessian, and that is not a metaphor. The observation program sealed it [13].
The curvature reader, measured. A prospective test compressed gradients two ways at identical reconstruction error, 0.298 for both arms, and asked which arm an optimizer with a given curvature preferred. The distortion of the update direction in the curvature metric flipped with the curvature profile, twelve of twelve heads in each direction, and the blind projected variance tracked the flip twelve of twelve while reconstruction error, identical by construction, predicted nothing at Spearman negative 0.20. Under an isotropic curvature the two arms tied and reconstruction tracked perfectly, which is the statement that reconstruction error is the curvature reader's distortion at identity curvature and nothing more. The read operator can be a query bank, a projector, or a Hessian.
The boundary, measured on a real model. The same design on a real logistic classifier, with the exact Hessian as the read operator, confirmed that the anti arm was worst 300 of 300 times, so the curvature reader governs the task, and found a clean flip only 82 of 300 times. The diagnosis is the one chapter 4 section 4.4 turned into a dial. In a trained model, the high-curvature directions are the high-gradient-energy directions, because both come from the same data matrix, so the curvature and the signal are coupled and a reconstruction-optimal compression already protects what the optimizer reads. The flip needs misalignment, and here there is none. The record carries it as a bound on the flip rather than a refutation of the mechanism.
For gradient boosting the reading is direct. The leaf step of equation 7.3 is a curvature-weighted read of the gradient, and anything done to the gradient upstream, subsampling rows, quantizing histograms, compressing for distributed training, is judged by the curvature reader and not by how well it reconstructs the gradient.
7.3 Why boosted trees rule tabular data, and where they do not
The session says boosted trees still rule tabular data and names where they do not. Text, images, and extreme sparsity. The book gives the reason in its own terms and then the measured answer to when they win.
A tree reads axis-aligned splits. Its read subspace is the span of the coordinate axes it splits on, and a boosted ensemble of trees reads the union. A signal that lies along a coordinate is read in one split. A signal that lies along a dense direction, a weighted sum of many coordinates, needs a staircase of splits to approximate, and the staircase costs capacity that a linear reader gets free. Tabular data has signal on the axes, because the columns were chosen by someone who thought they mattered. Text and images have signal in dense directions of a representation that no column names, and that is why chapters 11 and 12 use learned encoders there and why chapter 6's formula tool added projections to give formulas access to all features at once.
When the ensemble wins, on the author's benchmark. Chapter 6 gave the five-dataset table. Gradient boosting won decisively on a 15000-row signal dataset, won on a four-feature banknote dataset, won narrowly on a 30-feature medical dataset, and lost to a three-feature formula on two small datasets. The larger 31-dataset run and its independent analysis found the pattern behind that [23, 25]. The formula's advantage falls as the training size grows, a correlation of negative 0.59 across datasets at a p of 5 in ten thousand. It also falls as the ensemble's own score rises, correlation negative 0.562, which is consistent with a default ensemble being over-parameterized on small, low-dimensional tables where a two-term formula is nearer the right capacity. The number the analysis called the most decision-relevant one available is predictive.
$$\begin{gathered} \Pr[\text{formula beats boosting on a new dataset}]=0.345\ \text{overall}, \\ 0.589\ \text{for } N<800, \qquad \text{predictive interval }[-0.165,\ +0.125]. \end{gathered} \tag{7.4}$$
An interval spanning nearly a third of the F1 scale. The record's one-line summary is that which method wins is a property of the dataset, not of the methods, and that is the book's reading too. The ensemble is the better observer on some datasets and the formula on others, and the dataset decides.
7.4 Sidebar. Comparing to an ensemble fairly
The comparison in section 7.3 was first reported with a sigma column that chapter 6 section 6.4 retracted. This sidebar is what was learned from trying to rescue it, and it is the chapter's reason for being.
The protocol. Every arm gets the identical fold protocol, the same repetitions, the same seed, discovery and tuning on the training fold, scoring on the test fold. That much is chapter 6. The correction of chapter 8 section 8.5 then applies, because repeated cross-validation folds share training rows [4].
$$\mathrm{se}_{\mathrm{NB}}=\hat\sigma\sqrt{\frac1n+\rho},\qquad \rho=\frac{n_{\mathrm{test}}}{n_{\mathrm{train}}}=\frac1{k-1}\ \text{for }k\text{ folds},\qquad \mathrm{se}_{\mathrm{NB}}\to\hat\sigma\sqrt{\rho}\ \text{as }n\to\infty. \tag{7.5}$$
Under that correction nine wins became three, seventeen datasets became indeterminate, and an independent review ran five analyses to see whether any could resolve the seventeen from the data already collected. A Bayesian correlated test with a region of practical equivalence. An equivalence test at the paper's own margin. Dataset-level inference. More folds. Hierarchical pooling. All five resolved zero of seventeen, and three of them decided exactly the same three wins and eleven losses as the corrected frequentist test, which means they re-encoded the correction rather than adding information. The three mechanisms behind the five negatives are the sidebar's content, because each is a rule for the reader's own comparisons.
Repeats are exhausted. The corrected standard error of equation 7.5 has a floor, the fold standard deviation times the square root of rho, and at a thousand folds the benchmark sat within 0.2 percent of it. Two hundred repetitions and five give nearly the same interval. More repeats of the same split are not evidence.
The fold lever cancels itself. Raising the fold count lowers rho, but each test fold shrinks, so the per-fold standard deviation grows like the square root of the fold count. Measured, ten folds against five gave a ratio of 1.334 against the predicted 1.414, and twenty against five gave 1.937 against 2.000. The interval width as a function of folds is nearly flat, 0.945 at ten and a minimum of 0.921 near thirty-three, so the whole available narrowing is 8 to 11 percent and all of it is captured by ten folds. Applied to the published values it decided none of the seventeen, because an 11 percent narrowing only rescues a case whose statistic already sits within a hair of the line, and the closest one sat at 1.68.
There is no population effect to borrow. Between-dataset heterogeneity was 93 to 95 percent of the variance, with the between-dataset scale at 0.063, twelve times the paper's declared equivalence band of 0.005. The Bayesian analysis found that certifying equivalence would need a band of 0.073. The hierarchical analysis found the between-dataset scale of 0.063. Those are the same quantity reached from opposite directions, and they are why no margin works. Pooling also shrinks the surviving wins unevenly. The largest, at 0.1746, shrank 42.9 percent to 0.0997.
The redesign. What would resolve the seventeen is not more of the same. Measure learning curves rather than points, training at a grid of sizes from fifty rows to the full set, with ten folds and twenty repetitions per point, so that the size effect is estimated within each dataset where the heterogeneity cancels, in a model with one intercept per dataset.
$$\begin{gathered} \Delta F_1^{(i)}(n)=\alpha_i+\beta\,\log n+\varepsilon, \\ n_{\mathrm{cross}}^{(i)}=\text{the training size at which the ensemble overtakes the formula}. \end{gathered} \tag{7.6}$$
The crossing size is a scalar with a plain reading and is far more stable than a difference of two F1 values. Declare the small-data boundary in advance and test it on datasets not used to find it, because the subgroup of seventeen has a median effect of 0.006 at a selection-adjusted p of 0.964, which is a power problem with exactly one fix. And store the per-fold differences, because every analysis so far assumed the fold correlation from a heuristic and nobody checked it against the folds [30].
For a project comparing anything to a boosted ensemble, the sidebar is a checklist. Identical protocol. Corrected interval. Ten folds, not two hundred repetitions. No pooling across datasets to rescue one. A learning curve if the claim is about size. And the crossing size, not the sigma, as the headline.
7.5 Early stopping is a harness
The practical craft of gradient boosting is the trade between learning rate and tree count, the handling of categorical features, and early stopping on a validation fold. The last is chapter 8's material. Early stopping chooses the number of trees by watching a validation score, which makes the validation fold part of the training procedure. A tree count chosen on the test fold has let the harness read the test fold, and the reported score is about the harness. The fold that stops the boosting must be inside the training data of the fold that scores it, exactly as chapter 4 said of feature selection.
The learning rate and the tree count are two dials on one budget. A smaller rate with more trees is the same capacity spent more slowly, and chapter 4's rule applies. A verdict at one budget is not a verdict at another.
7.6 The preregistration checkpoint
The project preregistration is due Wednesday, and the session reads two or three aloud so that the class can test falsifiability rather than plausibility. Chapter 8 section 8.8 gives the eight fields, and the four the deck names, hypothesis, metric, baseline, and split, map onto them as the claim, the primary outcome, the instrument control, and the manifest. The threshold the deck asks for is the falsification bar. Write the bar so that a number can miss it. A hypothesis that the model will perform well cannot fail and will be returned. A hypothesis that the corrected interval on the difference from a default gradient-boosting baseline, under ten-fold cross-validation with seed 0, excludes zero at 95 percent can.
Commit the file. The hash goes in the checkpoint submission, and the final report is graded against it.
7.7 What an ensemble report must state
A project report that uses an ensemble states the following.
- The single-model baseline it was compared against, and the formula-search result of chapter 6 if one was run.
- The comparison as a corrected interval on the difference, with folds, repetitions, and seed, and never as a sigma count.
- The stopping rule. How the tree count was chosen, and on which fold.
- The importances, named as impurity or permutation, with the bias of each stated.
- The dataset size and the crossing size, if the claim is that the ensemble wins because the data is large.
- The preregistration hash, and whether the report's headline was covered by it.
A report that says the ensemble won and gives one number will be returned.
Exercises
Warm-up
- State what bagging removes and what it cannot remove, in terms of equation 7.1.
- Why does a random forest subsample features at each split?
- Name the bias of impurity importance and the bias of permutation importance.
- Explain why an AdaBoost learner with error one half receives weight zero.
- Why does the second-order leaf value shrink toward zero when few rows support a leaf?
- State what the reader of a gradient is and what its read operator is, and name the sealed result.
- Why did the flip appear on a synthetic curvature reader and not on a real logistic model?
- Why do boosted trees rule tabular data and not images, in terms of read subspaces?
- State the one-line summary of the 31-dataset comparison.
- Why are more repetitions of the same split not evidence?
- What single scalar does the redesign propose as the headline, and why is it more stable than a difference of F1 values?
- Why must the early-stopping fold sit inside the scoring fold's training data?
By hand
- Trees have variance 1 and pairwise correlation 0.5. Compute the variance of a bagged average of 10 trees and of 100 trees, by equation 7.1. State the floor.
- Compute the AdaBoost weight of equation 7.2 for weighted errors 0.2, 0.4, and 0.5.
- A leaf holds rows with gradient sum negative 10 and curvature sum 20. Compute the leaf value at regularization 0 and at 5.
- For logistic loss the curvature of a row is p times one minus p. Compute it at predicted probabilities 0.5, 0.9, and 0.99, and state which rows the curvature reader weighs most.
- Fold standard deviation is 0.02, a thousand folds, and rho is one quarter. Compute the corrected standard error of equation 7.5 and its floor, and the percentage by which the error exceeds the floor.
- Compute rho for five, ten, and twenty folds.
- An unpooled effect of 0.1746 shrinks to 0.0997. Compute the shrinkage as a percentage.
- The probability that a formula beats boosting on a new small dataset is 0.589. Compute the odds, and state whether a project on a 500-row table should expect the ensemble to win.
Programming
- Fit a single tree, a bagged ensemble, a random forest, and gradient boosting on your project dataset under one ten-fold protocol with a fixed seed. Report the mean and corrected interval of each model's difference from the single tree.
- Compute impurity and permutation importances for the random forest. Report the top five under each and the overlap, and identify one feature whose rank the impurity bias inflates.
- Fit gradient boosting with early stopping on a validation fold inside each training fold, and again with early stopping on the test fold. Report both scores and the difference.
- Sweep the learning rate and tree count at fixed product and report the score at each pair. State whether the ranking of two settings changes with the product.
- Subsample your dataset at five sizes from fifty rows to full, fit the formula of chapter 6 and gradient boosting at each, and plot the difference against log size. Report the crossing size of equation 7.6 if one exists.
- Store the per-fold differences of exercise 21 tagged by repetition and fold, and estimate the fold correlation from them. Report it beside the heuristic one over k minus one.
- Take the gradient of your boosting model's loss at one iteration and compress it two ways at matched error, one by variance and one against the row curvatures of equation 7.3. Report the change in the next iteration's loss under each.
Answers to the warm-up and by-hand problems are collected in the answer key at the end of the book.
Homework 7. Beat the ensemble fairly
Assigned in week 7, due Sunday of week 8. Ten points. Uses your project dataset. The project preregistration is a separate deliverable due Wednesday of week 7.
Part A, four readers (3 points). Programming exercise 21. Four models, one protocol, corrected intervals.
Part B, the stopping rule (2 points). Programming exercise 23. Both scores and one sentence on which one the report may quote.
Part C, the curve (3 points). Programming exercise 25. The plot and the crossing size, or the statement that none exists within your data.
Part D, the statement (2 points). The six items of section 7.7.
Preregistration. This homework's prediction is the project preregistration itself. Include its hash. Graded on having been made, and in week 16 on whether the report's headline was covered by it.
Sources for every number
Paths are relative to a checkout of the named repository, at the commit and with the access status listed in appendix A, all under github.com/ahb-sjsu unless appendix A says otherwise. Shas, DOIs, and versions are as recorded in the source files on 2026-09-03. A row is reproduced by opening the cited lines at that commit, and where a row names a script the command is the one the repository's README gives for it.
| Section | Claim | Source |
|---|---|---|
| 7.1 | bagging variance, out-of-bag estimation, random forests, importances, AdaBoost | Hastie, Tibshirani, Friedman, ESL 2e chapters 15 and 10.1; TSK 2e 4.10 |
| 7.2 | second-order leaf values, logistic curvature | ESL 2e 10.9 to 10.13; XGBoost introduction to boosted trees |
| 7.2 | curvature reader, identical reconstruction 0.298, flip twelve of twelve both, projected variance twelve of twelve, reconstruction Spearman negative 0.20, identity curvature tie | geometric-observation\experiments\GO2-gradient-curvature-NOTES.md:1-40; geometric-observation\claims\LEDGER.md row GO-B |
| 7.2 | real logistic model, exact Hessian, anti 300 of 300, flip 82 of 300, coupling diagnosis, bound not refutation | geometric-observation\claims\LEDGER.md row GO-B-optim-D4 |
| 7.3 | the five-dataset outcomes | theory-radar\README.md:100-140 |
| 7.3 | correlation negative 0.59 at p 4.8e-4 with size, negative 0.562 at p 0.001 with the ensemble's score, predictive 0.345 and 0.589, interval negative 0.165 to 0.125, the one-line summary | constraint-gap\review\INDETERMINATES.md:60-80; constraint-gap\review\REDESIGN.md:45-70 |
| 7.4 | nine to three, seventeen indeterminate, five analyses zero resolved, three re-encode the correction | constraint-gap\review\INDETERMINATES.md:1-40 |
| 7.4 | the floor within 0.2 percent, fold ratios 1.334 and 1.937, width 0.945 and 0.921, 8 to 11 percent, closest at 1.68 | constraint-gap\review\INDETERMINATES.md:40-60 |
| 7.4 | heterogeneity 93 to 95 percent, Q 446 on 30, scale 0.063, band 0.005, ROPE 0.073, shrinkage 0.1746 to 0.0997 at 42.9 percent | constraint-gap\review\INDETERMINATES.md:55-95 |
| 7.4 | the redesign, grid 50 to N, ten folds, twenty repetitions, crossing size, the 800-row boundary declared in advance, seventeen at median 0.006 and p 0.964, store the folds | constraint-gap\review\REDESIGN.md:1-110 |
| 7.6 | the preregistration fields | instructor working documents, not public [11], ECE_514-01_FA26_session-outlines.md:157-176; chapter 8 section 8.8 of this book |
previous, Chapter 6. Classification, the classifier as an observer ยท next, Chapter 8. The evaluation is an observer too