Search

Search papers and lessons

Oblivious Decision Tree

Level 3 · 12 min read

An oblivious decision tree asks the same question at every node of a level, so a depth-d tree is d questions plus a lookup table with 2 to the power d entries.

On this page

  • Colour = topic mix
  • Discrete math
  • Probability
  • Calculus
  • Classical models
  • Learning basics
  • Losses & regularization
  • ReadReady to readNot yet

TL;DR

An oblivious decision tree is a decision tree with one strict rule: every node on the same level asks the same question, meaning the same feature compared with the same threshold. Once the tree is trained, its answers to the questions pick one leaf out of a fixed list, and each leaf holds one number. The rule makes the tree small, fast to evaluate and hard to overfit, which is why it is a popular small learner inside boosting.

Builds on: Decision Tree · Leads to: CatBoost, NODE

Where it's used

Boosted models in CatBoost. CatBoost, the open-source gradient boosting library released by Yandex, builds its models from oblivious trees by default. Gradient Boosting adds many small trees one after another, each fitted to the errors the earlier trees left behind. Using oblivious trees as those small trees keeps every member of a large ensemble simple to store and to score.

Fast scoring in production. An oblivious tree of depth dd always does exactly dd comparisons and then one table lookup. Scoring a large batch of rows is therefore a fixed sequence of the same operations for every row, which is easy to run in parallel on CPUs and GPUs and easy to keep at a predictable latency.

Tabular deep learning. The NODE architecture (Neural Oblivious Decision Ensembles, 2019) builds a neural network out of many differentiable oblivious trees, trained with gradient descent. Spreadsheet-style data, with rows of numbers and categories, has long been a strength of tree models, and NODE tries to bring that strength into networks that can be trained by gradient descent.

How it works

Take a tiny model that predicts a score from two inputs, xx and yy. Training has already happened, and the tree has two questions. Question 1 is "is xx at least 3?" Question 2 is "is yy at least 1?" The tree is oblivious: level 1 has one node, which asks question 1, and both nodes on level 2 ask question 2. This gives four leaves with values:

Question 1 answerQuestion 2 answerLeaf numberLeaf value
nono01
noyes12
yesno25
yesyes38

Now predict the score for three points.

  1. Start at the root with the point (x,y)=(4,0)(x, y) = (4, 0). Ask question 1: is 44 at least 33? Yes. The tree follows the yes branch. Check: the no branch was never looked at.
  2. Move to level 2 and ask question 2 again. Both branches use the same question, yy at least 11. Is 00 at least 11? No. Check: the path is yes then no, which is leaf 2.
  3. Read the leaf value. Leaf 2 holds 5, so the prediction is 5. Check: the table row for "yes, no" says 5.
  4. Write the answers as bits to get the index. Yes is 1 and no is 0, with the level 1 answer as the high bit. The bits "10" are 2 in binary, which matches leaf 2. Check: 2⋅1+1⋅0=22 \cdot 1 + 1 \cdot 0 = 2.
  5. Score the point (1,5)(1, 5). Question 1 says no (1 is not at least 3), question 2 says yes (5 is at least 1). The bits are "01", so the index is 1 and the prediction is 2. Check: 2⋅0+1⋅1=12 \cdot 0 + 1 \cdot 1 = 1.
  6. Score the point (3,1)(3, 1). Both answers are yes, since 3≥33 \ge 3 and 1≥11 \ge 1. The bits are "11", so the index is 3 and the prediction is 8. Check: 2⋅1+1⋅1=32 \cdot 1 + 1 \cdot 1 = 3.
flowchart TD
  A["Level 1: x at least 3?"] -->|"no"| B["Level 2: y at least 1?"]
  A -->|"yes"| C["Level 2: y at least 1?"]
  B -->|"no"| L0["Leaf 0: value 1"]
  B -->|"yes"| L1["Leaf 1: value 2"]
  C -->|"no"| L2["Leaf 2: value 5"]
  C -->|"yes"| L3["Leaf 3: value 8"]

The diagram shows the difference from an ordinary tree. Both nodes on level 2 ask the same question, so the tree is a grid of tests, not a free branching structure. The price is that the second question cannot depend on the first answer, as the next sections explain.

The math

Definition: Oblivious decision tree

A tree of depth dd has one binary test per level, bℓ(x)=1[xjℓ≥tℓ]b_\ell(\mathbf{x}) = \mathbf{1}[x_{j_\ell} \geq t_\ell] for ℓ=1,…,d\ell = 1, \ldots, d, where jℓj_\ell is a feature index and tℓt_\ell is a threshold. Every node on level ℓ\ell uses this same test. The leaf for input x\mathbf{x} has index idx⁡(x)=∑ℓ=1d2 d−ℓ bℓ(x)\operatorname{idx}(\mathbf{x}) = \sum_{\ell=1}^{d} 2^{\,d-\ell}\, b_\ell(\mathbf{x}), and the prediction is f(x)=vidx⁡(x)f(\mathbf{x}) = v_{\operatorname{idx}(\mathbf{x})} for a table vv of 2d2^d leaf values.

Step 1 in symbols: one question per level

The test bℓb_\ell is a yes or no answer, written as 1 or 0. The bracket 1[⋅]\mathbf{1}[\cdot] is 1 when the condition inside is true and 0 otherwise. For the example, d=2d = 2, b1(x)=1[x≥3]b_1(\mathbf{x}) = \mathbf{1}[x \geq 3] and b2(x)=1[y≥1]b_2(\mathbf{x}) = \mathbf{1}[y \geq 1]. The subscript on bℓb_\ell is the level, not the node. Every node on level ℓ\ell uses the same jℓj_\ell and tℓt_\ell, which is what "oblivious" means.

Step 3 in symbols: the leaf index

The index is a binary number. Level 1 has weight 2 d−12^{\,d-1} and the last level has weight 20=12^0 = 1. For d=2d = 2, idx⁡=2 b1+b2\operatorname{idx} = 2\, b_1 + b_2. Check: the point (4,0)(4, 0) has b1=1b_1 = 1 and b2=0b_2 = 0, so idx⁡=2⋅1+0=2\operatorname{idx} = 2 \cdot 1 + 0 = 2, which is leaf 2 with value v2=5v_2 = 5.

Step 4 in symbols: fitting the tests and the table

Training picks the tests level by level. Suppose the squared error is the loss and rir_i is the target (or the residual, in boosting) for training point ii. Each leaf value is the mean of the targets that land in it, vk=1∣Lk∣∑i∈Lkriv_k = \frac{1}{|L_k|}\sum_{i \in L_k} r_i, where LkL_k is the set of training points in leaf kk. To choose the test for level ℓ\ell, the algorithm tries candidate pairs (feature, threshold). For each candidate, it splits every current leaf by the same test and measures the total squared error, ∑k∑i∈Lk(ri−vk)2\sum_k \sum_{i \in L_k} (r_i - v_k)^2. The pair with the lowest total error wins. A candidate is therefore scored on all leaves at once, not one node at a time.

Counting shows the structural difference. A depth-dd oblivious tree stores dd split conditions and 2d2^d leaf values. An ordinary depth-dd decision tree can have up to 2d−12^d - 1 internal nodes, each with its own feature and threshold, so it may store far more conditions for the same depth.

Worked examples

Example
1. A single question (tiny)

A depth-1 oblivious tree tests "is xx at least 3?". Below 3 the leaf value is 1, and at 3 or above it is 5.

  1. Input x=2x = 2. Is 2≥32 \geq 3? No. Bit b1=0b_1 = 0, index 0, value 1.
  2. Input x=3x = 3. Is 3≥33 \geq 3? Yes. Bit b1=1b_1 = 1, index 1, value 5.
  3. The rule for x=3x = 3 is the boundary case. The threshold counts as "at least", so equality takes the yes branch.

Answers: x=2x = 2 gives 1, and x=3x = 3 gives 5.

Example
2. Choosing the first test (standard)

Four training points, each with a residual rr (the value still to be explained):

xx1256
rr23-1-2
  1. Score the constant model, with no test. The mean residual is (2+3−1−2)/4=0.5(2 + 3 - 1 - 2)/4 = 0.5. The deviations are 1.51.5, 2.52.5, −1.5-1.5 and −2.5-2.5, and their squares sum to 2.25+6.25+2.25+6.25=172.25 + 6.25 + 2.25 + 6.25 = 17.
  2. Try the test "is xx at least 3?". The yes side holds x=5,6x = 5, 6 with residuals −1,−2-1, -2, mean −1.5-1.5, and squared error 0.25+0.25=0.50.25 + 0.25 = 0.5. The no side holds x=1,2x = 1, 2 with residuals 2,32, 3, mean 2.52.5, and squared error 0.25+0.25=0.50.25 + 0.25 = 0.5.
  3. Add the two sides: the total error is 0.5+0.5=1.00.5 + 0.5 = 1.0. The reduction from 17 is 16. Check: any threshold between 2 and 5 gives the same split, so the choice of threshold in that range does not matter.
  4. Try the test "is xx at least 1.5?". The no side holds only x=1x = 1, with error 0. The yes side holds residuals 2,3,−1,−22, 3, -1, -2, which have mean 0.50.5 and squared error 2.25+6.25+2.25+6.25=172.25 + 6.25 + 2.25 + 6.25 = 17. The total is 17, so the reduction is 0.
  5. The first test is therefore "is xx at least 3?", with leaf values −1.5-1.5 for the yes side and 2.52.5 for the no side. The no side is the one with smaller xx values, and its leaf value is its mean, 2.5.

Answer: of the two tests tried, "is xx at least 3?" gives the lower total error, 1.0 down from 17. It is also the best split of these four points, since the other splits leave more error.

Example
3. A realistic count (model size)

Suppose a boosted model has 500 oblivious trees of depth 6. Each tree stores 6 split conditions, so the model stores 500⋅6=3000500 \cdot 6 = 3000 conditions, and each tree has 26=642^6 = 64 leaf values, so 500⋅64=32000500 \cdot 64 = 32000 leaf values in total.

  1. An ordinary depth-6 tree has up to 26−1=632^6 - 1 = 63 internal nodes, each with its own condition. For 500 trees, that is up to 500⋅63=31500500 \cdot 63 = 31500 conditions.
  2. Scoring one row takes 6 comparisons per tree in both designs, because the path of an ordinary tree is also at most 6 steps. The difference is storage and the batch structure, not the count per row.
  3. In the oblivious case, every row in a batch performs the same 6 comparisons for a given tree, so the work can be written as one vector operation per level. That is the source of the speed advantage in practice.

Answer: the oblivious model stores 3000 split conditions against up to 31500 for the ordinary version, at the same depth and the same number of comparisons per row.

Try it: an oblivious tree has depth 8. How many leaf values does it store, and how many split conditions? Answer: 28=2562^8 = 256 leaf values and 8 split conditions.

Common mistakes and tradeoffs

It is tempting to think an oblivious tree is just a shallow ordinary tree. In fact it is a different object. Depth dd always gives 2d2^d leaves, so a depth-10 tree stores 1024 values even if the training data fills only a few of its leaves. Empty leaves need a fallback value, usually 0 or a prior mean.

It is tempting to think the shared test cannot model feature interactions. In fact it can, because a deeper level can test the same feature at a different threshold, and two features can appear on different levels. What it cannot do is let the second question depend on the first answer. A rule such as "if income is high, ask about debt, otherwise ask about age" needs an ordinary tree, because the two branches must ask the same question.

It is tempting to think oblivious trees are more accurate than ordinary trees. In fact a single oblivious tree is usually less accurate than a fully grown ordinary tree on the same data, because it has fewer possible shapes. Their strength is as members of an ensemble: the rigid structure acts as a regularizer, and each tree is simple to store and to evaluate.

Use an oblivious tree when you are building many small trees for boosting or tabular prediction, when fast and predictable scoring matters, and when a regular structure helps the model generalize. Do not use it when the decision logic is a long chain of different questions per branch, such as a triage checklist, or when you need very deep trees, because 2d2^d grows quickly. Alternatives are the ordinary tree (flexible, prone to overfitting alone), random forests (many ordinary trees with averaging) and ordered boosting (a training method that uses the same oblivious trees).

History

In the 1990s, machine learning researchers studied trees that use one test per level under names such as decision tables and oblivious decision trees. Ron Kohavi's 1995 work on oblivious decision trees and graphs is one early reference, and its goal was the same as today's: a compact model that is hard to overfit. The idea was known but used mostly in niche settings, because ordinary trees were more flexible and the tools for ensembles were still developing.

The idea returned in 2017 and 2018 when the CatBoost team at Yandex used oblivious trees as the default base learner in a gradient boosting library, which made the structure common in practical tabular work. In 2019 the NODE paper turned oblivious trees into differentiable units inside a neural network. Both uses rely on the same property: the shared test per level makes the model regular and easy to evaluate in bulk.

Recap

  • An oblivious tree uses one test per level, and every node on that level shares it.
  • A depth-dd tree has dd tests and 2d2^d leaves. The leaf is found by reading the answers as a binary number.
  • Training picks each level's test to reduce the total error over all current leaves, and each leaf value is a mean.
  • The structure is fast and regular and works well as a small learner in boosting, but it is usually weaker on its own than an ordinary tree.

Read next: CatBoost for how the trees are used in boosting, Gradient Boosting for the ensemble they usually sit in, and NODE for the neural version.

Check yourself

QuestionWhat is the defining rule that makes a tree oblivious?Show answer

Every node on the same level uses the same test, meaning the same feature and the same threshold. Nodes on different levels may use different tests.

QuestionA depth-3 oblivious tree has how many leaves, and how many split conditions does it store?Show answer

It has 23=82^3 = 8 leaves and 3 split conditions, one per level.

QuestionWhy does the shared test make scoring fast and easy to run in bulk?Show answer

Every row goes through the same sequence of comparisons, one per level, and then one table lookup. The work is the same for every row, so it can be written as vector operations across a batch, with no per-node branching that depends on earlier paths.

QuestionA team wants a rule that asks about income first, then asks about debt if income is high and about age if income is low. Can an oblivious tree represent this exactly?Show answer

No. The second question must be the same for both branches on that level, so an oblivious tree cannot ask about debt on one side and about age on the other. An ordinary tree can represent it.

Sources