Skip to content

CatBoost

CatBoost fits gradient-boosted trees with built-in categorical processing. Trace an ordered category statistic and distinguish it from ordered boosting and time-aware validation.

CatBoost is an open-source library for gradient-boosted decision trees, with built-in processing of categorical features. A credit-risk model can therefore combine numerical ratios with categories such as industry or region without treating arbitrary category codes as a numerical ranking. Its handling of labels during training is especially relevant when a seemingly useful category feature could reveal the outcome it is meant to predict.

Two mechanisms that share an ordering principle

The original CatBoost paper, §§3–5, distinguishes:
  • Ordered category statistics: construct a training row's target-based category feature from earlier rows in a training permutation. Its own label is excluded. This addresses target leakage through the feature.
  • Ordered boosting: calculate a row's training gradient using a supporting prediction based on an earlier prefix of the permutation. This addresses prediction shift caused by evaluating training gradients against predictions already influenced by the same targets. CatBoost uses an efficient implementation of this principle.
These are separate mechanisms. The paper's Plain boosting mode still has ordered category statistics; the word Plain does not mean that categories must be encoded externally.

An encoding that cannot read its own answer

Consider a deliberately small illustration of an ordered target statistic. Each observation has a sector category and a binary target: default within a hypothetical one-year horizon is 11, otherwise 00. Fix the prior at p=0.5p=0.5, independently of these observations, and give it smoothing weight a=2a=2.

For a row with category cc, define the toy feature

z(c)=Sc+apNc+a,z(c)=\frac{S_c+a p}{N_c+a},
where NcN_c is the number of earlier rows with category cc in the chosen permutation, and ScS_c is the sum of their labels. “Earlier” here means earlier in the permutation, rather than earlier on the calendar.

Take two training rows, both category A, in the stipulated order below. Encode each row before adding its label to the history.

Permutation positionOwn labelEarlier A labelsFeature supplied to this row
First11None(0+2×0.5)/(0+2)=0.5(0+2\times0.5)/(0+2)=0.5
Second00[1][1](1+2×0.5)/(1+2)=2/3(1+2\times0.5)/(1+2)=2/3

The second feature is 2/32/3 even though its own label is 00. Changing that label would leave its feature unchanged. The smoothing has a simple independent interpretation: the fixed prior contributes one positive and one negative pseudocount. The first row sees just those pseudocounts; the second sees them plus the earlier positive label.

Synthetic two-row training permutation for category A. A fixed prior of 0.5 with weight 2 gives the first row feature 0.5. After its label 1 enters the history, the second row receives 2/3. Each row's own label is excluded; permutation position is not calendar time.
Synthetic two-row training permutation for category A. A fixed prior of 0.5 with weight 2 gives the first row feature 0.5. After its label 1 enters the history, the second row receives 2/3. Each row's own label is excluded; permutation position is not calendar time.
Original exact toy ledger for a binary default target over a hypothetical one-year horizon. The prior and smoothing weight are stipulated. This illustrates one ordered-statistic idea, rather than a fitted CatBoost model, its default settings or its full categorical-feature pipeline.
For a held-out observation, target-dependent category statistics use training labels, rather than held-out answers. The CatBoost FAQ explains why those features can use a longer history at validation or prediction time than an individual training row had available.

What to check in an actual fit

Built-in categorical processing includes more than the toy mean above. The categorical-feature documentation describes category combinations and one-hot treatment for small category sets in supported modes. The transformation documentation lists several statistic types, including a counter that does not depend on labels. Do not assume every category receives the same target mean.
The current parameter reference offers boosting_type="Ordered" and "Plain". Defaults depend on the processing unit, dataset size and learning mode; ordered boosting is not a universal default. Record the library version and actual settings used in the experiment.
For financial forecasting, an artificial training permutation does not establish a valid test of future performance. Features must reflect information available at the forecast timestamp. Training labels must have finished their outcome horizons before they are used; overlapping label intervals can also require purging. Keep tuning separate from the final test period to limit overfitting and look-ahead bias.
The documented has_time setting preserves input order instead of applying random permutations in categorical transformation and tree-structure selection. It does not check when a label became observable or design a train/test split. Sorting by observation start time can still put an unfinished earlier label into the information set.
For this separate validation problem, Finance-aware validation develops a label-interval exclusion ledger and distinguishes purging from an embargo. The full lesson requires membership and has a public preview.

Sources

Last updated
  • catboost
  • machine learning
  • categorical features
  • gradient boosting
  • target leakage
← Back to the glossaryBack to top ↑