Sub topic 13
CatBoost: symmetric trees
This chapter assumes you know how decision trees split data, what a boosted ensemble is, and the basics of CatBoost's depth parameter. It covers what a symmetric tree is, why CatBoost uses it, and what you give up.
What a symmetric tree is
In an ordinary decision tree, each node picks its own best split. The left child might test age > 40 while the right child tests plan == "pro". A symmetric tree, also called an oblivious tree, uses one split condition for every node at the same depth. A tree of depth 3 has exactly three conditions, and each leaf is identified by the three yes/no answers.
A tree of depth d always has 2^d leaves. At each level, CatBoost chooses the single split that gives the best total gain across all nodes at that level.
Why CatBoost uses them
- Regularization. The shared-split rule is a strong constraint. The tree cannot carve out a tiny region of the data with a unique path, so it overfits less. This is part of why CatBoost often works well with little tuning.
- Fast prediction. To find a leaf, the model evaluates
dconditions and combines the results into a binary number. That number is the leaf index, so no pointer-chasing through nodes is needed. The conditions can also be evaluated in a vectorized way, which makes inference quick on CPUs. - Compact models. A tree is stored as
dsplits plus2^dleaf values.
What you give up
Symmetric trees are less flexible. A normal tree can spend its splits where the data is complicated and leave simple regions alone. A symmetric tree must apply the same split everywhere at a level, even where it helps little. If the real structure differs a lot between regions, you may need more depth or more trees to match a leaf-wise model.
The following table compares the two approaches:
| Property | Leaf-wise tree (LightGBM default) | Symmetric tree (CatBoost default) |
|---|---|---|
| Splits per level | Different at each node | One shared split |
| Leaves | Set by `num_leaves` | Always `2^depth` |
| Main complexity control | `num_leaves`, `min_data_in_leaf` | `depth` |
| Overfitting tendency | Higher on small data | Lower |
| Prediction | Walk the tree | Compute a leaf index |
Choosing the tree type in CatBoost
Symmetric trees are the default, set by grow_policy="SymmetricTree". CatBoost also offers Depthwise and Lossguide, which grow ordinary trees. Lossguide is leaf-wise and takes max_leaves.
from catboost import CatBoostClassifier
symmetric = CatBoostClassifier(depth=6, grow_policy="SymmetricTree", verbose=0)
leafwise = CatBoostClassifier(
grow_policy="Lossguide", max_leaves=31, min_data_in_leaf=20, verbose=0
)
print(symmetric.get_params()["grow_policy"], leafwise.get_params()["grow_policy"])Depth also controls cost. Leaves double with each level, so depth 10 has 1024 leaves per tree. Depths of 4 to 8 are a common range to try. Past that, training slows and overfitting becomes likely.
Exercise
A CatBoost model uses symmetric trees with depth 7. How many leaves does each tree have, and why can the tree not place a deep, narrow path through one small region of the data?
Show answer
Each tree has 2^7 = 128 leaves. Every node on a level must use the same split condition, so a path cannot specialize to one region. Any split added at a level applies to the whole level.