7 routes42 sections324 units

Unit 3.3 · about 5 h

146 / 324

AdaBoost and gradient boosting

Boosting turns weak rules into strong models by fitting what is left over. The same loop powers the gradient boosting libraries, so its failure modes of noise chasing and late overfitting follow you into production.

  • derive
  • implement

You can now

  • Derive the AdaBoost reweighting step of error rate, learner weight and distribution update, and run one round by hand.
  • Derive pseudo-residual fitting for squared and logistic loss and explain shrinkage, interaction depth and early stopping.
  • Implement stage-wise boosting around stumps, match sklearn on a toy, and diagnose noise sensitivity and overfitting by iteration count.

Covers

  • AdaBoost sample weighting and weak learners
  • Gradient boosting, pseudo-residuals, shrinkage and early stopping

Study, in this order

4 steps

  1. HoML Chapter 6: AdaBoost and gradient boosting
    Hands-On Machine Learning with Scikit-Learn and PyTorch - nonlinear classical models

    Book Chapter 6: AdaBoost and Gradient Boosting (printed pp. 207-214). Notebook 06 cells: AdaBoost with the step-by-step weight update cells, Gradient Boosting with the residual-fitting chain and the learning_rate 1.0 versus 0.05 comparison

    Depth · Drop algorithm='SAMME' from the AdaBoost cell: sklearn 1.9 removed the argument and raises TypeError, and SAMME is now the only mode.

  2. ISLP Chapter 8: boosting regression trees
    ISLP - tree-based methods and support vector machines

    Section 8.2.3 with Algorithm 8.2 and the three tuning parameters \(B\), shrinkage \(\lambda\) and interaction depth \(d\) (pp. 347 to 350)

  3. sklearn AdaBoost usage
    scikit-learn - neighbors, SVMs, trees and ensembles

    1.11.7 AdaBoost with 1.11.7.1 Usage: SAMME for classification, default decision stumps, and n_estimators with learning_rate as the main knobs

  4. sklearn gradient boosting: loss, shrinkage and subsampling
    scikit-learn - neighbors, SVMs, trees and ensembles

    1.11.1.2.5 Shrinkage via learning rate (learning_rate at or below 0.1 with large n_estimators) and 1.11.1.2.6 Subsampling (subsample 0.5, OOB pessimistic so prefer cross-validation)

Focus on

  • AdaBoost scores the round by the weighted error \(r\), pays the learner \(\alpha = \text{learning\_rate} \times \ln((1 - r)/r)\), multiplies wrong-point weights by \(\exp(\alpha)\) and renormalizes. The hand round gives \(r = 0.25\), \(\alpha = 0.5493\) and weights \(\left[\begin{smallmatrix}0.2113&0.2113&0.366&0.2113\end{smallmatrix}\right]\), matching estimator_weights_.
  • Gradient boosting fits each tree to pseudo-residuals, the negative gradients of the loss. For squared loss those are ordinary residuals, and the target mean plus a depth-2 tree fit on the residuals exactly equals a one-tree GBM at learning rate 1.0.
  • Shrinkage, depth and count interact: small \(\lambda\) needs large \(B\) with typical values 0.01 or 0.001, depth-1 stumps give additive single-variable terms, and subsample 0.5 adds bagging noise.
  • Boosting uses no bootstrap and each tree depends on its predecessors, so \(B\) is a genuine overfitting knob. Choose it by validation or early stopping, unlike bagging counts.

Reproduce closed-book

Run one AdaBoost round by hand on X = [0, 1, 2, 3] with y = [0, 1, 0, 1] and learning_rate 0.5: stump threshold 0.5 (2.5 ties; sklearn picks 0.5), \(r = 0.25\), \(\alpha = 0.5493\), new weights \(\left[\begin{smallmatrix}0.2113&0.2113&0.366&0.2113\end{smallmatrix}\right]\). Confirm \(\alpha\) against AdaBoostClassifier estimator_weights_. Then show GradientBoostingRegressor with learning_rate 1.0, one tree and max_depth 2 equals the target mean plus a depth-2 DecisionTreeRegressor fit on the residuals, on 50 points with \(x\) uniform on \([0, 4)\) and \(y = \sin(x)\) plus noise 0.05 at seed 0.

Traps

  • Copying algorithm='SAMME' from the notebook raises TypeError in sklearn 1.9. The parameter is gone and discrete SAMME is the only behavior.
  • AdaBoost pushes weight exponentially onto mistakes, so mislabeled points attract ever more attention. Noisy labels hurt it more than they hurt bagging.
  • The learning_rate 1.0 residual demo is didactic. Real runs shrink to 0.1 or below with many more trees, or the residual fit jumps past good solutions.

Practice

ISLP Chapter 8, Applied exercise 10: boosting on Hitters salary

Exercise 10 (p. 366), parts (a) to (g): 1000 trees over a shrinkage range, train and test MSE plots, comparison with Chapters 3 and 6 regressions and with bagging, variable importance

Install the ISLP package for the Hitters data, drop the rows with missing Salary, log-transform salary, use the first 200 rows for training, and report the shrinkage value with the lowest test MSE.

Self-test

  1. A stump has weighted error 0.25 with learning_rate 0.5. What learner weight does AdaBoost assign, and what happens to a wrong point starting at 0.25?

  2. Why does boosting depth-1 stumps produce an additive model?

  3. A GBM with 5000 trees, learning_rate 0.5 and no validation set scores perfectly in training but poorly on new data. What broke and what is the fix?

  4. How does boosting reuse data differently from bagging?

Completion criterion

Stop when

Your hand round matches sklearn weights, your stump booster reproduces the one-tree GBM identity, and the Hitters sweep shows test MSE dipping then rising with a stated choice of shrinkage and tree count.

Mark passed, then open 3.4 Only mark this when you can do it without notes.

Leads to

Comes after

Resources for this unit

  • Hands-On Machine Learning with Scikit-Learn and PyTorch - nonlinear classical models
    Aurelien Geron (O'Reilly, 2025)primaryimplementation
    Read Chapters 3, 5 and 6 and the online Appendix C notebook as the first pass through performance measures, trees, ensembles and SVMs, running notebooks 03, 05 and 06 alongside. Vary depth, estimators, learning rate, k, C and RBF width under fixed splits.
  • scikit-learn - neighbors, SVMs, trees and ensembles
    scikit-learnreferencereference
    Check official estimator constraints, complexity, preprocessing needs, missing-value behavior and probability caveats. Do not use library calls as the mechanism implementation.
  • ISLP - tree-based methods and support vector machines
    James, Witten, Hastie, Tibshirani and Taylorrequiredtheory
    Use Chapters 8 and 9 with their Python labs for the statistical account of trees, bagging, random forests, boosting and SVMs that the notebooks leave implicit, and for model-choice and feature-importance arguments.

Also in this section

  • Deep-ML - tree, ensemble and kernel problems
    Deep-MLsupportpractice
    Use 138 Best Gini-Based Split, 20 Decision Tree Learning, 307 Bagging Classifier, 21 Pegasos Kernel SVM and 280 RBF Kernel as unit checks after the local implementation passes. Their tests were read in review; each card states what they pin, including tie and update-order conventions.
  • Probabilistic Machine Learning, Chapter 16: exemplar-based methods
    Kevin Murphysupporttheory
    Read Sections 16.1 to 16.1.3 for the KNN decision rule, the curse of dimensionality with the growing-hypercube example, and the speed section on k-d trees, hashing and approximate search.
  • XGBoost parameters and sklearn estimator interface
    XGBoost developersreferencereference
    Read the tree-booster parameter list for eta, depth, sampling and regularization names and defaults, and the sklearn page for early stopping with eval_set.
  • LightGBM parameters
    LightGBM developersreferencereference
    Read learning_rate, num_leaves, max_depth, min_data_in_leaf, feature_fraction, bagging_fraction with bagging_freq, lambda_l2 and early stopping defaults.
  • CatBoost common parameters and categorical features
    CatBoost developersreferencereference
    Read iterations, learning_rate, l2_leaf_reg, depth, grow_policy, subsample, rsm, boosting_type, use_best_model and one_hot_max_size defaults, plus native categorical handling.

Quick find

Search Michi

Type to search every route, section, unit, topic and resource.

Enter opens the first result Esc closes

Reference

Keyboard shortcuts

n
Continue to the first unit not passed
j / k
Next / previous unit
1 2 3
Toggle learned, practised, passed
/
Open search
?
Show this help
Esc
Close open panels