r/rstats • • 16h ago

qshap: Fast and exact Shapley decomposition of R² for tree ensembles

Post image
45 Upvotes

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.

Any feedback would be greatly appreciated!