Telnyx - Global Communications Platform ProviderHome
Voice AI AgentsText-to-SpeechSpeech-to-TextEmbeddingsSearch APIBrowser APIMeetingBotVoice DesignInference APIAgentSDKFunctionsStateful ActorsKVSQLDBStorageGlobal NumbersVoice APISIP TrunkingSMS APIEmail APIRCSWhatsAppWebRTCVerify APINumber ReputationNumber LookupDeepfake DetectionBranded CallingIoT SIMeSIMMobile VoicePrivate Wireless GatewaysVirtual Cross ConnectsCloud VPNGlobal IP200+ open-source buildsagent-signup.mdx402View all primitivesHealthcareFinanceTravel and HospitalityLogistics and TransportationContact CenterInsuranceRetail and E-CommerceSales and MarketingServices and DiningView all solutionsVoice AIVoice APIInferenceMobile VoiceSpeech-to-TextText-to-SpeechSIP TrunkingSMS APIEmail APIWhatsApp Business APIGlobal NumbersIoT SIM CardView all pricingOur NetworkGlobal communicationsEdge ComputeAgents PlatformPartnersCareersCustomer storiesResource centerMission Control PortalEventsVoice AI agent playbookSupport centerSETIDev DocsIntegrationsCode examplesBenchmarks
Contact salesLog in
Sign up
Contact salesLog in
Sign up
Start building

Social

Compare

  • Twilio
  • Bandwidth
  • Plivo
  • Vonage
  • Wasabi
  • Amazon S3
  • ElevenLabs
  • Vapi
  • Baseten
  • Together.ai
  • Amazon Connect
  • Lumen
  • Cloudflare
  • Resend
  • SendGrid
  • Mailgun

Resources

  • Release Notes
  • Acceptable Use
  • Terms and conditions
  • Website Terms and Conditions
  • Data and Privacy
  • Report Abuse
  • Privacy Policy
  • Cookie Policy
  • Law Enforcement
  • Trust Center

Company

  • Why Telnyx
  • Our Network
  • Global Coverage
  • Customer Stories
  • Careers
  • Country Specific Requirements

Social

Company

  • Our Network
  • Global Coverage
  • Release Notes
  • Careers
  • Voice AI
  • AI Glossary
  • Shop

Legal

  • Data and Privacy
  • Report Abuse
  • Privacy Policy
  • Cookie Policy
  • Law Enforcement
  • Acceptable Use
  • Trust Center
  • Country Specific Requirements
  • Website Terms and Conditions
  • Terms and Conditions of Service

Compare

  • ElevenLabs
  • Vapi
  • Baseten
  • Together.ai
  • Twilio
  • Bandwidth
  • Vonage
  • Amazon Connect
  • Lumen
  • Cloudflare
  • Resend
  • SendGrid
  • Mailgun
Telnyx
© Telnyx LLC 2026
ISO • PCI • HIPAA • GDPR • SOC2 Type II

Ask AI

  • GPT
  • Claude
  • Perplexity
  • Gemini
  • Grok
Back to Glossary

What is gradient boosting? How GBMs and boosted trees work

Gradient boosting builds a model from many small trees, each fixing the errors of the last. How GBMs work, XGBoost vs random forest, and Python code.

Emily Bowen
Editor: Emily Bowen

Updated October 2026

Gradient boosting is a machine learning technique that builds a prediction model one step at a time. Each step adds a small model, usually a decision tree, trained to correct the errors left by the steps before it. The finished model adds up the predictions of every step. In machine learning, GBM stands for gradient boosting machine, a model trained this way.

Each tree in a GBM is too simple to predict well on its own, yet a few hundred of them added in sequence make one of the most accurate models for tables of data.

In a 2022 benchmark of 45 tabular datasets, with every model tuned, tree-based models such as XGBoost still beat deep neural networks on tables of about 10,000 rows.

This content was generated with the assistance of AI. Our AI prompt chain workflow is carefully grounded and preferences .gov and .edu citations when available. All content is reviewed by a Telnyx employee to ensure accuracy, relevance, and a high standard of quality.

Sign up and start building.

Sign UpContact Us

What is gradient boosting?

Gradient boosting is a form of boosting, the family of methods that train simple models in sequence. Each new model concentrates on what the combined model still gets wrong.

In gradient boosting, each new model learns the negative gradient of a loss function: the direction the predictions should move to lower the error. Jerome Friedman of Stanford introduced the method in 2001 in Greedy function approximation.

The loss is a choice, so the same algorithm covers regression with squared or absolute error and classification with log loss.

How does gradient boosting work?

Gradient boosting starts from one constant prediction, then repeats a single step: fit a small tree to the current errors, and add a fraction of that tree's prediction to the model.

For regression with squared error, each round runs like this:

  1. The model starts by predicting the average of the target for every row.
  2. Each row's residual is its actual value minus the current prediction.
  3. A small decision tree learns to predict those residuals from the features.
  4. The tree's predictions are added to the model, scaled down by the learning rate.
  5. Steps 2 to 4 repeat for a set number of trees, or until a validation score stops improving.

In a toy set of six support calls, the one feature is how many issues each caller raised: 1, 1, 2, 3, 3 and 4. The target is each call's length in minutes: 5, 6, 7, 10, 11 and 15.

The starting prediction is the average, 9 minutes, for every call. The residuals run from -4 to +6 minutes. The mean squared error, the average of the squared residuals, is 11.7.

A decision tree divides rows on one feature at a time and predicts one constant value for each group it ends with, called a leaf. Each tree in this example makes a single split.

The first tree splits the calls at two issues or fewer, the split that most reduces the squared error of the residuals. It predicts a residual of -3 minutes for those three calls and +3 for the other three.

A learning rate of 0.5 adds half of each value, a larger step than the usual 0.1, chosen here to keep each round visible.

Calls with one or two issues now get 7.5 minutes, calls with three or four get 10.5. The error falls to 4.9. The second tree splits at three issues or fewer and the third at one, cutting the error to 1.9, then 1.0.

After 50 trees the model predicts 5.5, 5.5, 7, 10.5, 10.5 and 15 minutes. Calls with the same number of issues get the same prediction, because no tree can split rows that share every feature value.

At inference time, a trained GBM runs a new row through every tree and adds the starting average to the sum of the trees' scaled outputs.

Three charts of six support calls, plotting call length in minutes against issues raised. Round 0 predicts the average, 9 minutes, for every call, with a mean squared error of 11.7. Round 1 splits at two issues or fewer and predicts 7.5 and 10.5 minutes, cutting the error to 4.9. After three trees the prediction steps sit close to every call and the error is 1.0. Each tree fits what the model before it still gets wrong.

Gradient boosted decision trees

Gradient boosted decision trees (GBDT), also called gradient tree boosting, are gradient boosting with small decision trees as the models it adds. XGBoost, LightGBM, CatBoost and scikit-learn all implement this form.

Boosting keeps each tree shallow, so each one underfits on its own. The sequence of trees does the learning.

Tree depth sets which feature interactions a GBM can learn. A path through a tree three levels deep tests at most three features, such as a customer's plan, the time of day and the number of issues.

A tree with a single split, called a stump, can only learn each feature's effect on its own. scikit-learn's GradientBoostingRegressor defaults to trees three levels deep; its histogram-based estimators cap each tree at 31 leaves instead.

Gradient boosting for regression and classification

Gradient boosting runs the same loop for regression and classification with a different loss function, which decides what each new tree learns.

For regression with squared error, the negative gradient of the loss is the residual itself: the gap between the true value and the prediction. That is why each tree in the six-call example could fit the residuals directly.

Absolute error and Huber loss, which squares small errors and takes the absolute value of large ones, give outliers less pull on the model. Friedman's paper covers both.

For classification, a GBM adds its trees on the log-odds scale, the logarithm of p / (1 - p), where 0 means even odds. A sigmoid function turns the sum into a probability between 0 and 1.

The loss is log loss, which grows as the predicted probability of the true label falls. Each new tree fits the gap between the true label, 0 or 1, and the current predicted probability.

That gap is on the probability scale, while the model adds on the log-odds scale. So before a tree is added, each leaf's value is reset to the log-odds step that most lowers the loss for its rows, the line search in Friedman's algorithm.

With more than two classes, each round adds one tree per class.

Overfitting and early stopping

A GBM overfits when it keeps adding trees after its loss on held-out data stops falling. Tracking that loss shows where to stop.

On scikit-learn's diabetes dataset (442 patients, 10 features), a GradientBoostingRegressor with depth-3 trees and a learning rate of 0.1 trained on 331 rows and was scored on the other 111 (a random split, seed 0).

Validation error was lowest at 13 trees, a mean squared error of 3,514, against 4,965 for predicting the average. The same 111 rows chose that count, so 3,514 flatters the model.

By 500 trees, training error had fallen to 35 while validation error had climbed to 4,364, 24% above its low.

The extra trees had fit noise in the 331 training rows. Early stopping ends training once the validation loss has gone a set number of rounds without improving.

Training and validation error by number of trees on a diabetes dataset with 331 training rows and 111 validation rows, depth-3 trees and a learning rate of 0.1, on a log scale. Validation error is lowest at 13 trees, 3,514, against 4,965 for predicting the average, then climbs to 4,364 by 500 trees while training error falls to 35.

Gradient boosting in Python

scikit-learn's HistGradientBoostingClassifier trains a gradient boosted model in a few lines, with early stopping ending training once the held-out loss stops improving.

The example trains it on the breast cancer dataset that ships with scikit-learn (569 tumors, 30 features) and holds out 20% of the rows for testing:

Python
12345678910111213141516171819
from sklearn.datasets import load_breast_cancerfrom sklearn.ensemble import HistGradientBoostingClassifierfrom sklearn.model_selection import train_test_splitX, y = load_breast_cancer(return_X_y=True)X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=0)model = HistGradientBoostingClassifier( learning_rate=0.1, # how much of each new tree to add max_iter=500, # upper limit on the number of trees max_leaf_nodes=15, # size of each tree early_stopping=True, # hold out 10% of the training data... n_iter_no_change=10, # ...and stop after 10 trees without improvement random_state=0,)model.fit(X_train, y_train)print("trees built:", model.n_iter_)print("test accuracy:", round(model.score(X_test, y_test), 3))

The model stopped after 55 trees, 10 rounds after its best one. It classified 111 of the 114 test rows (97.4%) correctly. Four settings control it:

  • learning_rate scales each tree's contribution. scikit-learn's guide recommends 0.1 or lower, with max_iter set high enough that early stopping, not the cap, ends training.
  • max_iter caps the number of trees.
  • max_leaf_nodes (or max_depth) sets the size of each tree, which sets how many features can interact.
  • early_stopping holds out 10% of the training rows and stops after n_iter_no_change rounds without improvement.

Early stopping takes care of the tree count, which leaves the learning rate and tree size for hyperparameter tuning.

The older GradientBoostingClassifier has a subsample setting that trains each tree on a random fraction of the rows, typically half. Friedman called this stochastic gradient boosting.

Combined with a small learning rate, subsampling can further increase accuracy, according to scikit-learn's guide.

HistGradientBoostingClassifier bins each feature into at most 255 values before training and handles missing values and categorical features natively.

scikit-learn says the histogram version can be orders of magnitude faster than the older class above tens of thousands of rows.

XGBoost, LightGBM, and CatBoost

XGBoost, LightGBM and CatBoost are open-source libraries that implement gradient boosted decision trees. They run the same algorithm and differ in how they find splits, sample rows and handle categories.

LibraryPaperWhat it adds to gradient boosting
XGBoostChen and Guestrin, 2016A regularized objective, second-order gradient statistics, a learned default branch for missing values, and a system design that scales past billions of rows
LightGBMKe et al., 2017Histogram-based splits, sampling that keeps the rows with large gradients, bundling of features that are rarely nonzero together, and leaf-wise growth
CatBoostProkhorenkova et al., 2018Ordered boosting, which computes each row's residual with a model that never saw that row, and an ordered encoding of categorical features; both stop the label leaking into the model's own inputs. Symmetric trees use one split per level

The LightGBM paper reports training up to more than 20 times faster than conventional GBDT at almost the same accuracy. LightGBM targets data with many rows and many features. CatBoost targets data where many features are categorical.

Gradient boosting vs random forest

Gradient boosting adds shallow trees one after another, while a random forest grows deep trees independently and averages them.

In Leo Breiman's random forest, each tree trains on a sample of the rows drawn with replacement and picks from a random subset of features at every split. The trees grow deep and are not pruned.

A random forest averages deep trees that each overfit, which lowers variance. Gradient boosting adds shallow trees that each underfit, which lowers bias.

Adding trees to a random forest does not make it overfit: Breiman showed that its error converges to a limit as the forest grows. Adding trees to a GBM can, as the diabetes run showed, so the tree count has to be chosen.

Random forest trees can train in parallel because no tree depends on another. Boosting's shallow trees are faster to fit and predict than a forest's deep ones, according to scikit-learn's guide.

In the 2022 benchmark, the best tabular models were tree ensembles of both kinds, bagged random forests and boosted trees. scikit-learn's guide advises trying both on the problem at hand.

Gradient boosting compared with a random forest. Gradient boosting adds shallow trees one after another: each underfits on its own, they are combined by adding, scaled by the learning rate, the method lowers bias, and more trees can overfit, so the tree count has to be chosen. A random forest grows deep trees independently and averages them: each overfits on its own, averaging lowers variance, and its error converges to a limit as trees are added.

Advantages and limitations of gradient boosting

The main advantages of gradient boosting are accuracy on tabular data, little data preparation and interpretability. Its main limits are sequential training, overfitting, no extrapolation and weak results on raw text and images.

The advantages:

  • Strong accuracy on tables of numeric and categorical features.
  • Little preparation. Trees split on thresholds, so features need no scaling. XGBoost and scikit-learn's histogram estimators route missing values without imputation.
  • Interpretability. Permutation importance measures how much the score drops when one feature's values are shuffled. Partial dependence plots show how the prediction changes as one feature varies.

The limitations:

  • Sequential training. Each tree waits for the one before it. Libraries parallelize the work inside each tree, such as building feature histograms, but not across rounds.
  • Overfitting. More trees can raise validation error, as the diabetes run showed, so the tree count needs early stopping or a validation check.
  • No extrapolation. Each tree predicts constants learned from the training range. In the six-call example, a call with 6 issues, or 10, gets the same 15 minutes as a call with 4.
  • Raw text and images. Deep learning has driven the progress on text and image data, as the authors of the 2022 benchmark note. A GBM needs features someone has already extracted.

That limit sets the division of labor in a voice AI agent: the language model handles the conversation, while fields extracted from each finished call become a GBM's training rows.

The Telnyx Voice API hangup event records when a call started, why it ended and its audio quality. AI Insights extracts fields such as a 1-to-5 sentiment score from conversations with Telnyx voice AI agents.

Frequently asked questions

What does GBM stand for in machine learning?

In machine learning, GBM stands for gradient boosting machine: a model built by gradient boosting, usually from decision trees. The name comes from Friedman's 2001 paper.

In medicine, GBM means glioblastoma, a type of brain tumor.

What is the difference between gradient boosting and gradient descent?

Gradient descent improves a model by adjusting its parameters step by step, while gradient boosting improves it by adding a new model at each step.

Friedman framed boosting as gradient descent in function space: each step adds a whole function, a tree, instead of nudging a parameter.

What is the difference between AdaBoost and gradient boosting?

AdaBoost, from Yoav Freund and Robert Schapire, raises the weight of every training example the previous models misclassified. Gradient boosting instead fits each new model to the negative gradient of a chosen loss.

AdaBoost is a special case: gradient boosting with exponential loss recovers the AdaBoost algorithm, as scikit-learn's documentation notes.

Is XGBoost the same as gradient boosting?

XGBoost is a library that implements gradient boosting, so it runs the same algorithm. Its additions, such as a regularized objective, change how the trees are built, not what the model is.

How is the learning rate used in gradient boosting?

The learning rate scales each tree's contribution before it is added to the model. At 0.1, each tree moves the predictions a tenth of the way toward what it learned.

Smaller steps need more trees and tend to give better test error, according to scikit-learn's guide.

What are weak learners?

A weak learner is a model that predicts only a little better than chance, such as a decision stump with one split. Boosting combines many weak learners, trained in sequence, into one accurate model.

Sources

  • Friedman, J. H. (2001). Greedy function approximation: a gradient boosting machine. Annals of Statistics, 29(5), 1189 to 1232.
  • Friedman, J. H. (2002). Stochastic gradient boosting. Computational Statistics and Data Analysis, 38(4), 367 to 378.
  • Freund, Y., and Schapire, R. E. (1997). A decision-theoretic generalization of on-line learning and an application to boosting. Journal of Computer and System Sciences, 55(1), 119 to 139.
  • Breiman, L. (2001). Random forests. Machine Learning, 45, 5 to 32.
  • Chen, T., and Guestrin, C. (2016). XGBoost: a scalable tree boosting system. KDD 2016.
  • Ke, G., et al. (2017). LightGBM: a highly efficient gradient boosting decision tree. NeurIPS 2017.
  • Prokhorenkova, L., et al. (2018). CatBoost: unbiased boosting with categorical features. NeurIPS 2018.
  • Grinsztajn, L., Oyallon, E., and Varoquaux, G. (2022). Why do tree-based models still outperform deep learning on tabular data? NeurIPS 2022 Datasets and Benchmarks.
  • LightGBM documentation. Features: leaf-wise tree growth.
  • scikit-learn documentation. Ensembles: gradient boosting, random forests and other methods; GradientBoostingRegressor, GradientBoostingClassifier and HistGradientBoostingClassifier reference (version 1.6).
  • Telnyx. Structured insights and insight groups. Telnyx developer documentation.
  • Telnyx. Call hangup webhook. Telnyx API reference.
Share on Social

Jump to:

What is gradient boosting?How does gradient boosting work?Gradient boosted decision treesGradient boosting for regression and classificationGradient boosting in PythonXGBoost, LightGBM, and CatBoostGradient boosting vs random forestAdvantages and limitations of gradient boostingFrequently asked questionsSources

Sign up for emails of our latest articles and news