Paper commentary
Consistent Individualized Feature Attribution for Tree Ensembles
Tree SHAP gives consistent, exact feature attributions for tree ensembles
- Problem Common tree feature attributions can lower a feature's importance even when its true impact rises. That makes attributions across features impossible to compare reliably.
- Method Tree SHAP computes exact SHAP values for tree ensembles in polynomial time. Instead of visiting every feature subset, it tracks how much weight each subset size carries along the tree.
- Results Tree SHAP explains one XGBoost prediction in 0.08 seconds. Its attributions agree better with human intuition in a user study.
Why tree attributions can mislead
Tree ensembles such as gradient boosting machines and random forests are hard to read, so practitioners attach an importance value to each input feature. Those values can describe one prediction, which is individualized, or the whole dataset, which is global. Gain adds up the loss reduction from every split on a feature, and split count tallies how often a feature is used to split.
The Saabas method is the only tree-specific individualized method the authors know of.
The problem is inconsistency: a model can change so that a feature matters more, yet that feature's attribution falls. Gain, split count and Saabas all behave this way, while the authors note that only SHAP values and permutation-based methods are consistent. Without consistency, a large attribution no longer implies a large impact, so attributions can't be compared across features.
Figure 1 makes this concrete with two small regression trees. Model A is an AND rule on Cough and Fever, and Model B keeps that rule but raises the predicted value when Cough is Yes. The expected output is 20 for Model A and 25 for Model B, and the output for a person with both Cough and Fever is 80 for Model A and 90 for Model B. Because Cough now matters more, the tree splits on Cough first in Model B.
Saabas then gives Fever a larger attribution than Cough in Model B, which is the wrong ordering.
Among the global measures, only the mean magnitude of SHAP values and permutation give Cough more importance than Fever in Model B. A ranking error like this is what makes attribution values hard to trust.
Why SHAP values as the consistent choice
A consistent replacement needs a principled way to split each prediction among its features. The key idea is to explain each prediction with SHAP values, which give every feature its average contribution over all orders in which features can be revealed. Each contribution is a Shapley value computed over conditional expectations of the model output.
The authors expect this to work because SHAP values are the only additive attribution that keeps three properties together.
An additive attribution method writes the explanation as a constant plus a sum of per-feature values on binary indicators of observed features. Local accuracy means the attributions sum to the model output, missingness gives zero credit to features that are already missing, and consistency says that raising a feature's impact never lowers its attribution.
The Saabas method satisfies local accuracy and missingness but fails consistency.
For a subset S of features, the authors write f_x(S) as the expected model output given the observed features, \(f_x(S)=E[f(x)\mid x_S]\). The SHAP value of feature i is then a weighted sum of the change in that expected output when i joins S. The weight depends only on |S| and M, and the sum runs over every subset, which is exponential in M.
How Tree SHAP avoids subset enumeration
The key idea is to track, along the tree, how much weight each subset size carries instead of visiting each subset one at a time. The authors first write a slow estimator of the conditional expectation for one set S. At a split on an observed feature it follows the branch that x takes, and at a split on an unobserved feature it sends weight down both branches in proportion to node cover.
Running this for every subset in the sum costs O(T L^2 M) time.
The fast version keeps, for each path, a list of features with a zero fraction z, a one fraction o and a weight w that holds the proportion of sets of each cardinality. EXTEND adds a feature to the path and grows the subsets, while UNWIND removes an earlier extension. When a feature appears again on the path, UNWIND first undoes its earlier entry so that the feature isn't counted twice.
At each leaf, the recursion adds the leaf value times the path weight times the difference between the one and zero fractions to that path feature's attribution.
Keeping subset sizes separate matters because the weights in Equation 2 depend on the size of S. Because the SHAP values of a sum of functions add up, the same procedure works for sums of trees such as boosted ensembles.
Splitting out pairwise interactions
The authors extend SHAP values to pairs of features using the Shapley interaction index. The second difference \(\nabla_{ij}(S)=f_x(S\cup\{i,j\})-f_x(S\cup\{i\})-f_x(S\cup\{j\})+f_x(S)\) captures how the effect of feature i changes when j is also observed. Each interaction is split equally between the two features, so Φ_{i,j} equals Φ_{j,i}.
The main effect of a feature is what remains of its SHAP value after the interaction terms are subtracted, \(\Phi_{i,i}=\phi_i-\sum_{j\neq i}\Phi_{i,j}\). Computing the interaction sum directly is costly, so the authors reuse the tree recursion. They run the recursion once with feature j held present and once with j held absent, and the difference gives the interaction.
This gives O(T M L D^2) run time, since the process repeats for each feature.
The authors note that this computation doesn't enforce symmetry directly, yet the resulting Φ matrix is always symmetric. The authors argue that this separation can reveal interactions that would otherwise be missed, and Figure 10 in Section 5.5 illustrates it on NHANES I.
User study and runtime results
To test the credit allocation for Model A, the authors described the tree as a disease risk model. Participants were told that risk rose from 20 to 80 when a person had both Cough and Fever, and asked to split that 60 point change between the two features. The study used 34 participants from Amazon Mechanical Turk, who were not selected for machine learning expertise.
The authors found the equal split that SHAP gives to be the most intuitive answer. Fewer participants put more weight on Fever, the first feature split on, and fewer still followed the Saabas allocation that favours Cough.
On runtime, the authors compare Tree SHAP with brute force over Equation 2 and Algorithm 1 on XGBoost models with 50 trees. Their Figure 5 varies the number of input features and the maximum tree depth, and reports the time to explain one input vector. That shows the cost is practical at scale, but the text gives no brute-force time beside it and no numeric speed-up factor.
Supervised clustering and influential features
Supervised clustering runs the clustering on feature attributions instead of on raw input features. Attributions share the units of the model output, so a unit change in any attribution is comparable to a unit change in another. Figure 4 applies this to 2,000 individuals from the UCI census data, using an XGBoost model of 500 trees with maximum depth six and a shrinkage factor η of 0.005.
Each person's explanation is clustered hierarchically, which groups people who share reasons for a predicted outcome.
To quantify clustering quality, the authors track R2 as groups merge from one group per sample to a single group. On the census model, the figure labels the SHAP result as AUC 0.98 and the Saabas result as AUC 0.97, although the curves track R2. On the Alzheimer's model, which uses 200 gene expression module levels to predict CERAD cognitive scores, the labels are 0.96 for SHAP and 0.88 for Saabas.
The census gap is small, while the Alzheimer's gap is much larger, so the advantage of SHAP grouping is clearer on the second dataset.
For the influence test, the authors used a sentiment model trained on 11,712 airline tweets with 1,686 bag-of-words features. They explained 2,928 test tweets and, for each method, replaced the most influential negative feature with that feature's value from another random training tweet. If the chosen feature lowered the output, replacing it should raise the output, so a larger total increase marks a better choice.
Figure 7 compares five methods, and global methods replaced only one feature for the whole dataset, such as the word thank for gain and permutation.
SHAP summary and dependence plots on NHANES I
The authors trained an XGBoost Cox proportional hazards model on NHANES I survival data. They kept 9,932 individuals followed for up to 20 years for mortality, and based the choice of 7,000 trees of depth 3 on an 80/20 train/test split. The final model used η of 0.001 and 50% instance sub-sampling, and it was trained on all individuals.
Summary plots replace the usual bar chart: features are sorted by their global impact, and each person's SHAP value is drawn as a dot. Dots are colored by feature value and pile up vertically to show density, which gives a shape similar to a violin plot without a smoothing kernel width.
A partial dependence plot shows the expected output as one variable is fixed and varied, and it produces only lines. A SHAP dependence plot puts the feature value on the x-axis and its SHAP value on the y-axis, so each person adds one point. Coloring each dot by age shows that high systolic blood pressure matters more to the model for younger people, which the authors read as an interaction effect.
The authors suggest two possible reasons: high blood pressure is less surprising as people age, and it takes time to cause fatal complications.
Figure 10A shows the SHAP main effect of systolic blood pressure, which has little vertical spread because the interaction effects are removed.
Limitations
The user study uses one tree, Model A, and 34 participants from Amazon Mechanical Turk who weren't selected for machine learning expertise. The runtime comparison in Figure 5 uses XGBoost models with 50 trees, while the 0.08-second example uses a 1,000-tree model. Interaction values have an O(T M L D^2) cost, and the text gives no measured timing for them.
The clustering evidence covers two datasets, the census data and the Alzheimer's gene expression data, and compares only against Saabas. The figure labels are AUC even though the curves track R2, so those numbers need care. The influence test uses one sentiment model and one replacement procedure, and the text gives no final totals for each method.
The summary and dependence plots are shown on one NHANES I model, and the text doesn't test whether readers understand them better. The algorithm is stated for trees and sums of trees.
Paper info
- Authors
- Scott M. Lundberg, Gabriel G. Erion, Su-In Lee
- Venue
- arXiv · Preprint
- First published
- 2018-2-12
- Added
- 2026-11-12
- Updated
- 2019-3-7
- Version
- v3
- arXiv
- 1802.03888
- Category
- cs.LG · stat.ML
- Original paper terms
- arXiv non-exclusive 1.0
- What we show
- Paper info and commentary
AI commentary is a separate explanation from the original paper and may contain errors. The original paper and figures follow each source's terms of use and any rights noted separately.
Quote from the paper
Scott M. Lundberg, Gabriel G. Erion, Su-In Lee (2018). Consistent Individualized Feature Attribution for Tree Ensembles. arXiv:1802.03888v3. https://arxiv.org/abs/1802.03888v3
BibTeX
@misc{lundberg2018consistent,
title = {{Consistent Individualized Feature Attribution for Tree Ensembles}},
author = {Scott M. Lundberg and Gabriel G. Erion and Su-In Lee},
year = {2018},
eprint = {1802.03888},
archivePrefix = {arXiv},
url = {https://arxiv.org/abs/1802.03888v3}
}