r/rstats • u/Fine-Paramedic-4621 • 3h ago
qshap: Fast and exact Shapley decomposition of R² for tree ensembles
Hi r/rstats!
I'd like to share an R package I've been developing, qshap. Unlike conventional SHAP values that explain individual predictions, qshap decomposes GBDT model's R² into feature-specific contributions.
It supports XGBoost, LightGBM, and CatBoost, with both global and local explanations.
The CatBoost implementation is particularly fast: exact R² decomposition for 100,000 observations, 100 features, and 100 trees (depth 6) takes only 0.14 seconds on a single CPU core of an M1 MacBook Pro in our benchmarks.
Both R and Python packages are available on CRAN and PyPI, respectively.
- R: https://github.com/catstats/Q-SHAP_R
- Python: https://github.com/catstats/Q-SHAP
- Methodology paper (UAI 2025): https://proceedings.mlr.press/v286/jiang25a.html
- Software manuscript (preprint): https://arxiv.org/abs/2608.24104
Any feedback would be greatly appreciated!

