TL;DR
CatBoost is an open-source gradient boosting library, described in a 2017 paper by Prokhorenkova, Gusev, Vorobev, Dorogush and Gulin. The paper names a hidden flaw in standard boosting: each round's gradients are computed on the same examples the current model was fitted to, so the model's training-set predictions are systematically more accurate than its predictions on new data. It fixes this with ordered boosting, and it fixes the same leakage in the way categories are turned into numbers, using ordered target statistics.
On the benchmark datasets in the paper, CatBoost's stronger configuration reached lower logloss than LightGBM and XGBoost on every dataset listed in its comparison table.
Builds on: Gradient Boosting, Target Statistics, Decision Tree · Leads to: Ordered Boosting, the paper's central idea
Why it mattered
Gradient-boosted decision trees were the strongest method for tabular data, meaning tables of rows and columns with a mix of numbers and categories, and they remain widely used. Before this paper, the common ways of handling categories either blew up the number of columns, as one-hot encoding does for a column such as user ID, or leaked the target into the features. The paper showed that the leakage was a real, measurable effect, not just a theoretical worry, and that removing it helped on ordinary benchmarks.
The library took the paper's ideas into practice. CatBoost has been cited more than 9,000 times according to OpenAlex. The paper's introduction names web search, recommendation systems and weather forecasting as areas where gradient boosting is the main tool, and it points to click-through prediction as a setting where target statistics are widely used.
The problem
Gradient boosting builds a model in rounds. Each round fits a small tree to the errors the current model still makes, then adds it. The errors are estimated from the training set. For a training example , the error of the current model is computed using a model that was itself fitted using 's own target . This is target leakage.
The consequence is a prediction shift. The distribution of the model's output for a training example differs from its distribution for a new example. The model learns to correct errors that are partly artifacts of having seen the example, so its behaviour on new data is worse than its training fit suggests.
Categories add a second place where this happens. The standard fix is to replace a category with its target statistic, the average target over rows that share that category. If that average includes the row's own target, the feature leaks the answer. The paper shows that this breaks even in a simple case where every category is unique, so the statistic is literally the row's own label.
How it works
Take a tiny table with one categorical column, the city, and a binary target. The rows arrive in the order shown, and the chosen random order is the one written here.
| Row | City | Target |
|---|---|---|
| 1 | Paris | 1 |
| 2 | Paris | 0 |
| 3 | Rome | 1 |
| 4 | Paris | 1 |
The prior is and the smoothing weight is .
- Choose a random order of the rows. This order is . Here it is rows 1, 2, 3, 4 as shown. Check: each row has a position in the order, and no row is repeated.
- Compute each row's ordered target statistic from earlier rows only. Row 1 has no earlier rows, so its statistic is the prior, . Check: with no history, the only information is the prior.
- Continue down the order. Row 2 is Paris, and the earlier Paris row has target 1. Its statistic is . Check: the numerator adds the prior once, and the denominator counts the one earlier row plus the smoothing weight.
- Row 3 is Rome, with no earlier Rome rows. Its statistic is again . Check: a new category starts from the prior.
- Row 4 is Paris, with earlier Paris rows 1 and 2. The sum of their targets is and there are 2 of them. The statistic is . Check: row 4's own target, 1, is not in the sum, so the value does not leak it.
- Boost with ordered gradients. The residual for each row is computed with a model that has not seen that row. Each round of trees uses these unshifted residuals. Check: a row's residual never depends on its own target.
The diagram shows the loop that the paper runs for each boosting round.
flowchart TD A["Draw random row order"] --> B["Ordered target statistics using earlier rows"] B --> C["Residuals from models that did not see each row"] C --> D["Build one oblivious tree, scored on earlier rows"] D --> E["Add its leaf values to every supporting model"] E --> F["Test rows use statistics over all training rows"]
The math
Setup
The data is , with features and a target . Gradient boosting, which the paper writes in its Section 2, builds , where is a base predictor and is a step size. For squared loss, the negative gradient is the residual . The base predictors are oblivious decision trees, which use the same split condition at every node of one level.
Step 2 in symbols: the target statistic
The standard greedy target statistic for row and categorical feature is The sum includes , so enters . This is the leakage. The ordered version replaces the sums over all with a sum over , the rows earlier in the random order . For test rows, the statistic uses the whole training set.
Step 3 in symbols: the example that breaks the greedy statistic
Suppose every category is unique and each category has . The greedy statistic for row becomes . A single threshold then separates the classes perfectly on the training set. On test rows, where every category is new, the statistic is for every row, and the model cannot beat chance. The paper states the target property that avoids this: the distribution of given must be the same for training and test rows.
Step 4 in symbols: ordered boosting
Ordered boosting keeps a set of supporting models , where is trained on the first rows in the order . The residual for row is which is unshifted because never saw row . Keeping models costs too much, so CatBoost keeps about predictions, using permutations and models for the powers-of-two prefixes of each order. The paper's Table 1 gives the cost per iteration as both for computing gradients and for updating the models, so the extra permutations add a factor of rather than a factor of .
The theorem
The paper's Theorem 1 uses a regression with two binary features, , and two stumps. If each stump is fitted on an independent sample, the expected model equals the true function up to a term exponentially small in . If the same data is reused at both steps, the expected model is biased by The bias is inversely proportional to the data size. This is why the effect matters most on small datasets.
Choosing splits
For each candidate split in a tree, CatBoost computes leaf values from the earlier rows only, then scores the candidate by the cosine similarity between this vector and the gradient vector. The split with the highest similarity is kept. The same tree structure is then added to all supporting models, each with its own leaf values.
Results
The main comparison uses the stronger CatBoost configuration, which includes ordered target statistics, ordered boosting, and feature combinations. Appendix G of the paper reports logloss and zero-one loss, with relative increases for the baselines in brackets. A few rows:
| Dataset | CatBoost | LightGBM | XGBoost |
|---|---|---|---|
| Adult | 0.2695 | 0.2760 (+2.4%) | 0.2754 (+2.2%) |
| Amazon | 0.1394 | 0.1636 (+17%) | 0.1633 (+17%) |
| Epsilon | 0.2647 | 0.2703 (+1.5%) | 0.2993 (+11%) |
| Kick | 0.2855 | 0.2957 (+3.5%) | 0.2946 (+3.2%) |
The margins are smallest on three small datasets. On Appetency, Churn and Upselling, LightGBM and XGBoost come within 0.5 per cent of CatBoost's logloss.
The paper also tests a bare configuration, close to classical gradient boosting, against the baselines. Averaged over datasets, the bare CatBoost has 0.2 per cent better zero-one loss, while the baselines have 0.2 per cent better logloss. The authors conclude that the implementation is a fair base for the other ideas.
The ordered mode matters most on small data. Relative to the plain mode, ordered mode gives the largest gain on Adult and Internet, which have fewer than 40,000 training examples. In the raw setting, using the same permutation for target statistics and boosting gives an average 0.6 per cent lower logloss and 0.9 per cent lower zero-one loss than plain mode. Using independent permutations gives 0.5 per cent and 0.2 per cent. Feature combinations, going from one allowed combined feature to two, improve logloss by 1.86 per cent on average, and to three by 2.04 per cent. Using more permutations helps a little: three permutations give 0.19 per cent lower logloss than one, and nine give 0.38 per cent.
Limits. Speed is not the paper's strength. On the Epsilon dataset, the plain mode and LightGBM are the fastest, and ordered mode is about 1.7 times slower. The results come from benchmark datasets chosen by the authors, and each library's settings were tuned for the comparison.
Reading guide
- Section 1, Introduction: the two leakage problems, prediction shift and target statistics, and the claim that CatBoost beats XGBoost and LightGBM. Needs Gradient Boosting.
- Section 2, Background: the boosting setup, with the gradient step and the least-squares fit of the next tree. Needs Gradient Descent, Loss Function and Decision Tree. The Newton variant uses Newton-Raphson Method.
- Section 3, Categorical features: why one-hot encoding fails for high-cardinality columns, and the greedy, holdout, leave-one-out and ordered target statistics. Needs One-Hot Encoding and Target Statistics.
- Section 4, Prediction shift and ordered boosting: the shift analysis, Theorem 1 and the ordered boosting algorithm. Needs Ordered Boosting. Read the Theorem 1 proof only if you want the details.
- Section 5, Practical implementation: the oblivious trees, the cosine-similarity split score and the use of several permutations. The sections on oblivious trees are self-contained once you know that every split at one level uses the same condition.
- Section 6, Experiments: the tables above. Appendix G has the full numbers.
Check yourself
QuestionRecall: what is target leakage, and where does it appear in gradient boosting?Show answer
Target leakage is when a feature or a gradient is computed using the target of the same example that the model is being judged on or trained with. In boosting, the residuals used to fit each new tree are computed by a model that was itself fitted using those same examples, so the residuals are biased toward the training targets. The same happens in greedy target statistics, where a category's average includes the row's own target.
QuestionCompute: using the ordered target statistic with and , what is the statistic for the fourth row in the city example, if the earlier Paris rows had targets 1 and 1?Show answer
The sum of earlier targets is and the count is 2. The statistic is . The row's own target does not enter, because only earlier rows in the order are used.
QuestionWhy does the paper say the bias in Theorem 1 matters most for small datasets?Show answer
The bias is , which shrinks in proportion to . With few examples, the term is large, so reusing the same data for every step distorts the model more. This matches the experiments, where the gap between ordered and plain mode is largest on Adult and Internet, which both have under 40,000 training examples.
QuestionApplied: a team has a dataset of 20,000 rows with a column of 5,000 different product IDs. They are choosing between one-hot encoding and a target statistic. Which should they use, and what must they do to avoid leakage?Show answer
One-hot encoding would create 5,000 new columns, most of them almost always zero, so it is a poor fit for high-cardinality columns. A target statistic gives one number per product. To avoid leakage they should compute the statistic in the ordered way, using only earlier rows in a random order, and use the full training set only for test rows. Using a plain average that includes each row's own target would make the training fit look better than it is on new data.