- Introduced by
- Friedman, J. H.
- Year
- 2001
- Type
- Ensemble (sequential boosting of decision trees)
- Family
- Machine learning
What does it do?
Gradient boosting, introduced by Jerome Friedman in 2001, builds a predictive model as a sum of shallow decision trees added one at a time, each fitted to the errors of the current ensemble.
Friedman framed the procedure as gradient descent in function space, so the same boosting loop can handle different outcome types by changing the loss function. It is widely used for prediction on tabular data.
The intuition behind the method
Instead of building many trees in parallel and averaging them (as Random Forest does), gradient boosting builds trees one at a time. Each new tree focuses on the mistakes the current model still makes, which are the residuals. This sequential correction is analogous to gradient descent in ordinary optimization, but it operates in the space of prediction functions rather than parameter space. The final prediction is the sum of many small corrections, each nudging the ensemble toward the target. A small learning rate makes each step cautious, which regularizes the model and often improves generalization.
History
Jerome Friedman introduced gradient boosting in his 2001 Annals of Statistics paper, which treated stagewise additive tree expansions as steepest-descent optimization in function space. His 2002 paper, Stochastic gradient boosting, added random subsampling to the procedure. Later software implementations, including XGBoost, LightGBM, and CatBoost, follow the same general scheme with additional engineering.
When to use it
Choose gradient boosting for supervised prediction on tabular data (classification, regression, or ranking) when predictive accuracy is the main goal and the features mix continuous and categorical types. It captures nonlinear effects and feature interactions without specifying them in advance, and it does not assume normally distributed predictors. Very small samples are a weaker fit: little data remains for a validation set used in early stopping, and overfitting becomes more likely. In that case compare it against simpler regularized models using cross-validation. Avoid it when explicit coefficients or odds ratios are required (use logistic or linear regression instead), when models must be retrained very quickly (it is slower to retrain than Random Forest), or when a simple linear model already describes the relationship well.
Limitations and considerations
- Trees are added in sequence, so training cannot be parallelized across rounds as it can across the trees of a Random Forest; training time grows with the number of rounds.
- Several settings (learning rate, number of rounds, depth, subsampling fraction) trade off against each other, and poor choices of any one can degrade results.
- Predictions are not expressed as coefficients; an additive ensemble of many trees is hard to read without post-hoc tools.
- Under squared-error loss, large residuals from outlying observations drive the next tree, so the default loss is sensitive to noisy targets; robust losses are the usual remedy.
- Model size and inference cost grow with the number of trees, which can matter for edge deployment.
Source conditions do not replace independent scientific review or validation by an analysis engine.
Strengths
- The loss function is interchangeable: Friedman's 2001 framework gives algorithms for least-squares, least absolute deviation, and Huber-M regression, and for multiclass logistic classification, all within the same boosting loop.
- With least absolute deviation or Huber loss, the procedure is less sensitive to outliers, which the 2001 paper highlights for less clean data.
- The learning rate (shrinkage) and the subsampling fraction from the 2002 stochastic variant act as explicit, tunable regularizers.
- Because each tree is shallow but sequential, the model can capture interactions up to the chosen depth without these being specified in advance.
- Tree ensembles provide feature importance scores, and post-hoc tools such as SHAP can be applied to explain individual predictions. Importance rankings can shift with correlated features and with hyperparameters, so check their stability across retrains before relying on them.
Applications
- Credit scoring and default prediction in finance.
- Click-through rate and conversion prediction in digital marketing.
- Medical outcome prediction and disease risk stratification.
- Fraud detection and anomaly scoring on transactional data.
- Demand forecasting and supply chain optimization.
- Feature selection and variable importance analysis as a preprocessing step.
How it works
How it works
The model starts with a constant prediction: the value that minimizes the chosen loss function over all training observations (for example, the mean for squared-error regression, or the log-odds for log-loss classification). This is the base from which all subsequent corrections build.
Formula
F_0(x) = \arg\min_{\gamma} \sum_{i=1}^{n} L(y_i, \gamma)At each boosting round, the negative gradient of the loss function with respect to the current ensemble's predictions is computed for every training observation. For squared-error loss these are simply the ordinary residuals; for other losses they are generalized pseudo-residuals that encode the direction and magnitude of the remaining error.
Formula
r_{im} = -\left[\frac{\partial L(y_i, F(x_i))}{\partial F(x_i)}\right]_{F=F_{m-1}}A shallow regression tree (typically of depth 3–6) is fitted to the pseudo-residuals from the previous step, so the tree models the gradient of the loss rather than the original outcome. The tree partitions the feature space into regions and assigns each region a small correction. Depth controls how many feature interactions a single round can capture.
Formula
h_m = \arg\min_{h \in \mathcal{T}} \sum_{i=1}^{n} \left(r_{im} - h(x_i)\right)^2The ensemble is updated by adding the new tree's predictions scaled by a learning rate (shrinkage parameter eta, commonly 0.01–0.1). A smaller learning rate requires more trees but usually yields better out-of-sample performance by preventing over-reliance on any individual tree.
Formula
F_m(x) = F_{m-1}(x) + \eta \cdot h_m(x)The final prediction is the initial constant plus the scaled tree corrections accumulated over the M boosting rounds. For regression this is a continuous value; for binary classification it is passed through a sigmoid; for multiclass classification, class-specific ensembles are combined with a softmax.
Formula
\hat{y} = F_M(x) = F_0(x) + \sum_{m=1}^{M} \eta \cdot h_m(x)Common pitfalls
- Using a large learning rate with many rounds and no early stopping, which leads to overfitting of the training data.
- Using the test set, or the validation set used for early stopping, as if it were an independent estimate of performance; this inflates reported accuracy. Tune with k-fold cross-validation or a separate validation set, and report final performance once on untouched held-out data using metrics suited to the task.
- Ignoring class imbalance in classification: the initial constant reflects class proportions, and rare classes receive little correction unless class weights or a cost-sensitive loss are used.
- Treating default hyperparameters (for example, scikit-learn's n_estimators=100 and max_depth=3) as settings that are optimal for the data, rather than starting points to tune by cross-validation.
- Reading feature importance from gradient boosting as a causal effect; importance measures predictive relevance, not causal influence.
- Treating predicted probabilities as calibrated risks without checking; boosted models can be miscalibrated, so inspect calibration (for example with a calibration plot) before using probabilities as risk estimates.
Frequently asked questions
How is gradient boosting different from Random Forest?
Random Forest builds its trees independently, in parallel, on bootstrap samples and averages them. Gradient boosting builds trees one after another, each fitted to the residual errors of the current ensemble. This sequential correction can give higher accuracy on some problems, but the method is more sensitive to hyperparameters and easier to overfit.
How many boosting rounds should I use?
The optimal number depends on the learning rate and the complexity of the problem, so it should be chosen by early stopping on a validation set rather than fixed in advance. A typical starting point is a low learning rate (for example 0.01-0.1) with a generous upper bound on the number of trees, stopping when the validation metric no longer improves. Adjust these starting values to your data.
Which implementation should I use: sklearn, XGBoost, LightGBM, or CatBoost?
All implement the same core boosting scheme. XGBoost, LightGBM, and CatBoost are designed to scale to larger datasets than a basic in-memory implementation. CatBoost handles categorical features natively without manual encoding, LightGBM is built for speed on large data, and XGBoost has the broadest ecosystem support.
Can gradient boosting handle missing values?
Some implementations, such as XGBoost and LightGBM, handle missing values natively by learning a direction for missing observations at each split. Support differs across libraries and versions, so check the documentation of the version you use. Imputation before fitting is a safe default for any implementation.
Is gradient boosting suitable for small samples?
Use it with caution. With few observations, gradient boosting can overfit even with regularization, and a held-out validation set may be too small to support early stopping. Compare it with simpler models such as logistic regression or regularized linear regression using cross-validation.
Related methods
Sources
Friedman, J. H. (2001). Greedy function approximation: A gradient boosting machine. Annals of Statistics, 29(5), 1189–1232.
Open DOI referenceFriedman, J. H. (2002). Stochastic gradient boosting. Computational Statistics and Data Analysis, 38(4), 367–378.
Open DOI reference