| qshap-package | R Documentation |
The qshap package computes feature-specific R-squared values using Shapley decomposition of the total R-squared for boosting trees built in xgboost and lightgbm. It supports parallel computing.
The package provides fast computation of feature importance through Shapley values for tree ensemble models. Main functions include:
gazer(): Create a Q-SHAP explainer from a trained model
rsq(): Calculate feature-specific R-squared values
loss(): Calculate feature-specific loss contributions
plot(): Visualize R-squared values
The method uses polynomial-time complexity for Shapley value calculation and includes built-in support for multi-core processing.
Steven He, Zhongli Jiang, Min Zhang, Dabao Zhang
Zhongli Jiang, Min Zhang, and Dabao Zhang. 2025. Fast calculation of feature contributions in boosting trees. In Proceedings of the Forty-First Conference on Uncertainty in Artificial Intelligence (UAI '25), Vol. 286. JMLR.org, Article 82, 1859–1875.
Useful links:
library(xgboost)
set.seed(42)
n <- 100
p <- 100
X <- matrix(rnorm(n * p), nrow = n, ncol = p)
y <- X[, 1] - X[, 2] + rnorm(n, sd = 0.2)
model <- xgboost(X, y, nrounds = 15, max_depth = 2, verbosity = 0, nthread = 1)
explainer <- gazer(model)
phi_rsq <- rsq(explainer, X, y)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.