Abstract
Tree ensemble methods provide promising predictions with models difficult to interpret. Recent introduction of Shapley values for individualized feature contributions, accompanied with several fast computing algorithms for predicted values, shows intriguing results. However, individualizing coefficients of determination, aka $R^2$, for each feature is challenged by the underlying quadratic losses, although these coefficients allow us to comparatively assess single feature's contribution to tree ensembles. Here we propose an efficient algorithm, Q-SHAP, that reduces the computational complexity to polynomial time when calculating Shapley values related to quadratic losses. Our extensive simulation studies demonstrate that this approach not only enhances computational efficiency but also improves estimation accuracy of feature-specific coefficients of determination.
Introduction
In machine learning, "feature importance" is critical for understanding the drivers of model performance. While local importance methods like TreeSHAP explain individual predictions, assessing global importance—specifically how much each feature contributes to the overall model fit ($R^2$)—remains a significant challenge. The Shapley value is the gold standard for fair contribution, but its exact calculation is NP-hard due to the combinatorial explosion of feature subsets. Existing global methods like SAGE or SPVIM rely on Monte Carlo sampling, which is computationally expensive, often unstable, and struggles with high-dimensional data. Furthermore, decomposing $R^2$ is particularly difficult because it involves quadratic losses that do not decompose as easily as linear predictions.
Methods
The proposed Q-SHAP (Quadratic SHAP) algorithm is specifically designed for tree-based models to overcome these hurdles. The method relies on three key innovations:
- Quadratic Decomposition: The algorithm demonstrates that the Shapley value of a quadratic loss can be decomposed into a linear combination of Shapley values of the predicted values and the squared predicted values.
- Tree-Structure Leveraging: Rather than treating the model as a black box, Q-SHAP utilizes the internal nodes and leaves of the tree. It calculates global contributions by aggregating weighted predictions across pairs of leaf nodes.
- Polynomial Identities and IFFT: To handle the combinatorial complexity, Q-SHAP employs mathematical identities involving polynomial coefficients. The Inverse Fast Fourier Transform (IFFT) is used to evaluate these polynomials efficiently, ensuring numerical stability even for deep trees.
Crucially, Q-SHAP’s complexity is independent of the number of features ($p$), scaling instead with the number of leaves and tree depth. This makes it uniquely suited for "wide" datasets with thousands of features.
Results and Discussion
The performance of Q-SHAP was evaluated against SAGE and SPVIM using synthetic simulations and high-dimensional real-world datasets, including genomic (Prostate Cancer) and financial (S&P 500) data.
Computational Efficiency
Q-SHAP demonstrates massive speedups over existing methods. In a high-dimensional genomic dataset with over 17,000 features, SPVIM required 67 hours to complete, whereas Q-SHAP finished in just 128 seconds. As shown in Figure 4, Q-SHAP maintains a significantly lower computational footprint as sample size and feature counts increase.
Estimation Accuracy and Stability
In simulation studies across linear, interaction, and non-linear models, Q-SHAP consistently outperformed SAGE and SPVIM in terms of Mean Absolute Error (MAE). Unlike sampling-based methods that exhibit high variance, Q-SHAP provides a stable and theoretically grounded decomposition of $R^2$.
Limitations
While highly efficient for tree ensembles like XGBoost and Random Forests, Q-SHAP is model-specific and cannot be applied to other architectures like neural networks. Additionally, while it handles high feature counts well, its complexity scales with the square of the number of leaves ($L^2$), which may pose challenges for extremely wide trees.
Conclusion
Q-SHAP represents a significant advancement in model interpretability for tree ensembles. By reducing the complexity of global Shapley value calculation from exponential to polynomial time, it enables the accurate and efficient decomposition of $R^2$ even in high-dimensional settings where previous methods were computationally prohibitive.
Summary updated