Unit 3 of 8 · about 5 hours · derive, implement

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.

You'll be able to

  • 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 learnersGradient boosting, pseudo-residuals, shrinkage and early stopping
1

Read

In this order, only the parts listed

0 of 4 done

  1. HoML Chapter 6: AdaBoost and gradient boostingHands-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

    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 treesISLP - tree-based methods and support vector machines

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

  3. sklearn AdaBoost usagescikit-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 subsamplingscikit-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)

2

Focus on

  • AdaBoost scores the round by the weighted error , pays the learner , multiplies wrong-point weights by and renormalizes. The hand round gives , and weights , 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 needs large 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 is a genuine overfitting knob. Choose it by validation or early stopping, unlike bagging counts.
Common mistakes · 3
  • 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.
3

Try it yourself

Closed-book, before checking anything

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), , , new weights . Confirm 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 uniform on and plus noise 0.05 at seed 0.
4

Quiz yourself

Answer first, then mark it. Missed ones go to Review.

0 got · 0 missed

  1. 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?Answer

    . The wrong point goes to before renormalization, which is 0.366 after.

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

    Each stump splits on one variable, so each term is a function of one variable only. The sum over rounds is a sum of single-variable terms.

  3. 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?Answer

    Late trees overfit the residuals. Shrink the learning rate toward 0.1 or below, add row or column subsampling, and pick the iteration count by early stopping on validation.

  4. 4.How does boosting reuse data differently from bagging?Answer

    Bagging fits independent trees on bootstrap copies. Boosting refits the same data with modified weights or residuals, so each tree depends strongly on the ones before it.

5

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.

You're done 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.

Only when you can do this without notes.

Leads to

Notes

Resources · 3 for this unit, 5 more in the section
  • Hands-On Machine Learning with Scikit-Learn and PyTorch - nonlinear classical modelsAurelien Geron (O'Reilly, 2025) · primary

    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 ensemblesscikit-learn · reference

    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 machinesJames, Witten, Hastie, Tibshirani and Taylor · required

    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 problemsDeep-ML · support

    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 methodsKevin Murphy · support

    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 interfaceXGBoost developers · reference

    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 parametersLightGBM developers · reference

    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 featuresCatBoost developers · reference

    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.