Introduction
Tree-based models like XGBoost and Random Forests are widely used for their high accuracy on tabular data. However, explaining their predictions remains a significant challenge. Traditional feature importance metrics, such as Gain (impurity reduction) or Split Count (frequency of use), suffer from a fundamental flaw: inconsistency.
Inconsistency occurs when a model is modified such that a feature has a larger impact on the output, yet the attribution method assigns it a lower importance score. This makes it impossible to reliably compare features or trust global importance rankings. As shown in the comparison below, traditional methods often fail to maintain consistent rankings when model weights change, whereas Tree SHAP remains robust.
The Tree SHAP Algorithm
To address these issues, the authors propose Tree SHAP, a fast and exact algorithm for tree-based models based on SHAP (SHapley Additive exPlanation) values. Rooted in cooperative game theory, SHAP values are the only attribution method satisfying three critical properties: local accuracy, missingness, and consistency.
The primary technical innovation is reducing the computational complexity of calculating exact SHAP values from $O(TL2^M)$ to $O(TLD^2)$, where $T$ is the number of trees, $L$ is the number of leaves, $M$ is the number of features, and $D$ is the tree depth. This allows for real-time explanations of complex ensemble models. Additionally, the algorithm extends to capture SHAP Interaction Values, revealing how features behave in combination rather than just in isolation.
Applications and Insights
The authors validated Tree SHAP across several domains, including the UCI Census dataset, NHANES I health study, and genomic data.
Individualized Explanations and Supervised Clustering
Unlike global metrics, SHAP provides an explanation for every single prediction. By clustering samples based on these individualized attributions—a process called supervised clustering—researchers can identify subgroups with shared underlying reasons for an outcome. For example, in the UCI Census data, SHAP values distinguish between "young and single" and "married and well-educated" high-earners, revealing the different logic the model applies to different demographics.
Human Alignment and Feature Identification
A user study confirmed that SHAP's credit assignment aligns more closely with human intuition than other methods. In sentiment analysis tasks, SHAP was superior at identifying specific words responsible for negative model predictions, making it a more reliable tool for debugging and auditing models.
Conclusion
Tree SHAP provides a mathematically grounded, consistent, and computationally efficient way to interpret tree ensembles. Its immediate integration into core libraries like XGBoost and LightGBM underscores its practical utility. While currently limited to tree-based architectures, it sets a high standard for model-specific explanation methods. Future work includes scaling interaction calculations and extending similar efficiencies to other model classes like neural networks.
Summary updated