qshap: Fast Shapley Decomposition of for Gradient-Boosted Trees
Organizations: University of California, Irvine
Abstract
Numerous methods have been developed to quantify feature attributions in individual predictions for tree ensembles. However, many applications require global measures of feature contributions to overall model performance. Although local attribution scores can be aggregated to characterize feature importance, such summaries do not directly decompose measures of predictive performance, such as . This article introduces qshap, available in both R and Python, which provides Shapley decomposition of values for gradient-boosted decision trees (GBDTs) to quantify feature-specific contributions to model performance. By decomposing the quadratic loss of individual observations, qshap provides flexible tools to explore the importance of individual features and observations. qshap currently supports widely used GBDT implementations, including xgboost, lightgbm, and catboost, through a unified tree representation and efficient C++ backends. Its modular design can accommodate other GBDT implementations built from binary decision trees. In addition, we introduce a specialized backend for oblivious trees that exploits their symmetric structure to substantially accelerate computation.
Figures & tables
| Goal | Function | Return value |
|---|---|---|
| Build explainer | \code gazer() | \code qshap_tree_explainer |
| Feature-specific | \code rsq() | \code qshap_result |
| Local loss and -scale contributions | \code loss() | loss matrix |
| Visualization | \code plot() | S3 plot for \code qshap_result |
| Class | Role |
|---|---|
| \code simple_tree | Model-independent representation of one parsed tree. |
| \code tree_summary | Computation-ready tree summary used by the backend. |
| \code qshap_tree_explainer | Parsed model object returned by \code gazer(). |
| \code qshap_result | User-facing feature-specific result. |
Feature Attribution
Feature attribution estimates which input features or internal components contribute to a model’s predictions.
See all 225 papers