Gradient boosting

Gradient boosting is a machine learning technique that builds a strong predictor by adding small models, usually shallow decision trees, one at a time, each trained to correct the remaining errors of those before it.

Gradient boosting starts with a crude prediction, such as the average house price in a dataset. It then looks at where that prediction is wrong and trains a small decision tree to predict those errors. The tree's output, scaled down by a learning rate, is added to the running prediction, and the process repeats, often hundreds of times. Each new tree tackles whatever the ensemble so far still gets wrong.

The name comes from the maths. Strictly, each new tree is fitted to the negative gradient of a loss function, the direction in which the prediction should move to reduce the error. For the simple squared-error loss, that gradient is just the leftover error. The scikit-learn documentation describes the whole procedure as a kind of gradient descent in a space of functions rather than of parameters, and notes that even for classification the trees are regression trees, because gradients are continuous numbers.

Leo Breiman observed that boosting could be treated as an optimisation problem, and Jerome Friedman developed explicit gradient boosting algorithms in 1999 and 2001; Mason, Baxter, Bartlett and Frean described the general functional gradient view. The method has gone by several names, including gradient boosting machine and MART. Software made it a standard tool: XGBoost, described by Tianqi Chen and Carlos Guestrin in 2016, was built to scale beyond billions of examples, and gradient boosting has been used in the ranking systems of the search engines Yahoo and Yandex.

It remains a leading method for tables of structured data, the rows and columns of spreadsheets and databases. A 2022 study by Léo Grinsztajn, Edouard Oyallon and Gaël Varoquaux compared tree-based models such as XGBoost and random forests with deep learning on 45 tabular datasets and found the tree-based models still state of the art on medium-sized data of around 10,000 samples. Scikit-learn's documentation calls gradient-boosted trees an excellent model for tabular data.

The trade-offs are familiar. A boosted ensemble of hundreds of trees is much harder to interpret than one tree, though feature importance scores can be extracted. Too many rounds can overfit, so practitioners control the learning rate, tree depth, number of rounds and the fraction of data each tree sees. For anyone predicting churn, fraud or demand from business tables, gradient boosting is usually a strong baseline to try before reaching for a neural network.

Common questions

What is the difference between gradient boosting and a random forest?

Both combine many decision trees. A random forest grows deep trees independently on random samples of the data and averages them, which mainly reduces variance. Gradient boosting grows shallow trees one after another, each correcting the errors left by the previous ones, which mainly reduces bias.

What is XGBoost?

XGBoost is a widely used library for gradient-boosted trees, described in a 2016 paper by Tianqi Chen and Carlos Guestrin. It added a method for handling sparse data and an approximate way of finding tree splits on large datasets, and its authors reported that it scales beyond billions of examples.

Is gradient boosting better than deep learning?

For medium-sized tables of structured data, often yes. A 2022 study across 45 tabular datasets found tree-based models such as XGBoost still ahead of deep learning on data of around 10,000 samples. For images, audio and text, deep learning is far stronger.

Does gradient boosting overfit?

It can, because each round fits the training data more closely. Common controls are a small learning rate, shallow trees, training each tree on a random subsample of the data, and stopping when performance on held-out data stops improving.

Finding more

Search for "gradient boosted trees", "XGBoost vs random forest" or "tabular data deep learning comparison" to see where the method fits. Reliable sources include the documentation for libraries such as scikit-learn and XGBoost, the original papers on arXiv and in statistics journals, and benchmark studies that publish their datasets. Be wary of single competition results presented as general rules, since performance depends heavily on the data and on tuning.

Working out what this means for your business?

Aileron Shift builds the systems behind this site: AI newsrooms that research, write and publish on their own, marketing automation and WordPress hosting for companies that need to move faster than their competitors.