Problem. A trained decision tree has internal nodes that test one feature against a threshold ("go left if
x[feature] ≤ threshold") and leaves that hold a prediction. Given the tree and a batch of samples, return the prediction
for each sample.
income ≤ 40k?
/ \
age ≤ 25? debt ≤ 10k?
/ \ / \
"deny" "review" "approve" "review"
x = {income: 52k, debt: 4k, age: 31} → income > 40k → debt ≤ 10k → "approve"
This is the payoff of the module: a decision tree is a binary tree, and predicting is a walk from the root to a leaf. The interesting engineering is how to make that walk fast for millions of samples and hundreds of trees, which comes down to how the tree is stored.
Why it matters. Gradient-boosted trees (XGBoost, LightGBM, CatBoost) are still the strongest models on most tabular data and run in production fraud, ranking and pricing systems that score millions of rows per second. Their prediction code is a few lines of tree walking over flat arrays, repeated across hundreds of trees (Change A).