Learning rate and subsampling
Quick answer
Shrinkage scales the contribution of each new learner by a learning rate. Subsampling fits stages on a subset of training rows, adding randomness. Together with tree complexity and stage count, these parameters control how the ensemble learns. Examples are static and locally tested with Python 3.13.5, scikit-learn 1.8.0 and NumPy 2.3.5 where imported. ByteMind package execution is unverified.
Compare two shrinkage rates
from sklearn.ensemble import GradientBoostingRegressorX=[[0],[1],[2],[3]]y=[0,0,4,4]for rate in (0.25,0.5): m=GradientBoostingRegressor(n_estimators=1,learning_rate=rate,max_depth=1,random_state=7).fit(X,y) print(m.predict([[0],[3]]).tolist())Observed local output:
[1.5, 2.5][1.0, 3.0]Both begin at mean 2; the larger rate takes a larger first step.
How it works
The learning rate eta multiplies each correction. For a fixed fitted correction h, eta=0.1 moves the raw prediction by one tenth of h; eta=1 moves it by the full amount. A smaller rate can require more stages to reach similar training loss, and two learning-rate/stage-count combinations are not generally equivalent because future residuals differ. In scikit-learn GradientBoostingRegressor, n_estimators sets the maximum number of stages, max_depth limits each tree, and subsample below 1 fits stages using a fraction of training observations without replacement. This is stochastic gradient boosting, not the with-replacement bootstrap of bagging. It may improve generalization, but may also miss useful patterns in small data. Set random_state for reproducibility within the pinned environment. Keep the validation rows outside the stage subsampling pool. Histogram gradient boosting instead groups continuous feature values into bins and computes candidate splits from aggregated gradient statistics, reducing split-search work; it trades fine threshold resolution for efficiency. In scikit-learn HistGradientBoostingRegressor, max_iter controls iteration count, max_bins controls bin resolution, and l2_regularization penalizes leaf values. Do not pass subsample or n_estimators to this histogram estimator. It can handle missing numeric values natively in this release; other estimators and frameworks differ. Small data do not establish a speed advantage.
Fit a bounded histogram model
from sklearn.ensemble import HistGradientBoostingRegressorX=[[0.0],[0.0],[1.0],[1.0]]y=[0,0,4,4]m=HistGradientBoostingRegressor(max_iter=2,learning_rate=0.5,max_leaf_nodes=2,min_samples_leaf=1,early_stopping=False,random_state=7).fit(X,y)print(m.n_iter_)print([round(float(v),5) for v in m.predict([[0.0],[1.0]])])Observed local output:
2[0.5, 3.5]Two histogram-based updates reduce residuals in this small two-group fixture.
Common mistakes
Do not compare learning rates without considering stage count and depth. Do not assume subsampling means bootstrap replacement. Do not assume histogram boosting supports every classic gradient boosting parameter.
Practice and next steps
Compare an ensemble with rate 0.05 and 100 stages against one with rate 0.2 and 25 stages using the same validation split. Explain why equal products do not establish equal models. Complete the knowledge check and staged exercise. Next: Validation-based early stopping.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Learning rate and subsampling — knowledge check
Apply learning rate and subsampling to new examples.
F=10, h=-4, eta=0.25. Updated prediction?
Why is eta=0.1 with 100 stages not equivalent to eta=1 with 10 stages?
How does classic gradient boosting subsampling differ from bagging bootstrap?
What do histogram methods group?
Which parameter controls maximum iterations of HistGradientBoostingRegressor?