Skip to content

shapley

Weighted Mean SHAP and CI for Robust Feature Assessment in ML Grid

v0.7.0 · Mar 3, 2026 · MIT + file LICENSE

Description

This R package introduces Weighted Mean SHapley Additive exPlanations (WMSHAP), an innovative method for calculating SHAP values for a grid of fine-tuned base-learner machine learning models as well as stacked ensembles, a method not previously available due to the common reliance on single best-performing models. By integrating the weighted mean SHAP values from individual base-learners comprising the ensemble or individual base-learners in a tuning grid search, the package weights SHAP contributions according to each model's performance, assessed by multiple either R squared (for both regression and classification models). alternatively, this software also offers weighting SHAP values based on the area under the precision-recall curve (AUCPR), the area under the curve (AUC), and F2 measures for binary classifiers. It further extends this framework to implement weighted confidence intervals for weighted mean SHAP values, offering a more comprehensive and robust feature importance evaluation over a grid of machine learning models, instead of solely computing SHAP values for the best model. This methodology is particularly beneficial for addressing the severe class imbalance (class rarity) problem by providing a transparent, generalized measure of feature importance that mitigates the risk of reporting SHAP values for an overfitted or biased model and maintains robustness under severe class imbalance, where there is no universal criteria of identifying the absolute best model. Furthermore, the package implements hypothesis testing to ascertain the statistical significance of SHAP values for individual features, as well as comparative significance testing of SHAP contributions between features. Additionally, it tackles a critical gap in feature selection literature by presenting criteria for the automatic feature selection of the most important features across a grid of models or stacked ensembles, eliminating the need for arbitrary determination of the number of top features to be extracted. This utility is invaluable for researchers analyzing feature significance, particularly within severely imbalanced outcomes where conventional methods fall short. Moreover, it is also expected to report democratic feature importance across a grid of models, resulting in a more comprehensive and generalizable feature selection. The package further implements a novel method for visualizing SHAP values both at subject level and feature level as well as a plot for feature selection based on the weighted mean SHAP ratios.

Downloads

CRAN

599

Last 30 days

5937th

1.8K

Last 90 days

6.9K

Last year

Trend: +14.8% (30d vs prior 30d)

r2u CRAN

0

Last 30 days

26

Last 90 days

131

Last year

Trend: -100% (30d vs prior 30d)

CRAN Check Status

13 OK
Show all 13 flavors
Flavor Status
r-devel-linux-x86_64-debian-clang OK
r-devel-linux-x86_64-debian-gcc OK
r-devel-linux-x86_64-fedora-clang OK
r-devel-linux-x86_64-fedora-gcc OK
r-devel-windows-x86_64 OK
r-oldrel-macos-arm64 OK
r-oldrel-macos-x86_64 OK
r-oldrel-windows-x86_64 OK
r-patched-linux-x86_64 OK
r-release-linux-x86_64 OK
r-release-macos-arm64 OK
r-release-macos-x86_64 OK
r-release-windows-x86_64 OK

Check History

OK 13 OK · 0 NOTE · 0 WARNING · 0 ERROR · 0 FAILURE Jun 8, 2026
NOTE 12 OK · 1 NOTE · 0 WARNING · 0 ERROR · 0 FAILURE Jun 7, 2026
NOTE r-devel-linux-x86_64-debian-gcc

R code for possible problems

Found the following possibly unsafe calls:
Fatal error: cannot create 'R_TempDir'
OK 14 OK · 0 NOTE · 0 WARNING · 0 ERROR · 0 FAILURE Mar 10, 2026

Code intelligence has not been computed for this package yet.

Code

Structure

Lines of code

3,000

Files

37

Compiled share

0%

Has compiled src

No

Language breakdown

R 1,968 (65.6%)Docs 1,032 (34.4%)

API

Exported functions

9

Internal functions

3

Recent export changes

v0.6.0+1 shapley.domain.test
v0.5+2 shapley.feature.test, shapley.table  −2 shapley.feature.selection, shapley.test

Testing & CI

Has tests

No

Test-to-code ratio

0.00

testthat edition

CI present

No

CI type

[]

PR gated

No

Docs

Return-value doc rate

100%

\dontrun example ratio

100%

Roxygen coverage

100%

Has pkgdown

No

NEWS present

No

Health & Security signals

Informational signals; not verdicts.

on.exit coverage

Unsafe pattern score

0

Dep constraint coverage

100%

Secret pattern count

0

Bundled 3rd-party code

2 items

Portability & License

Min R version

3.5.0

System requirements

C++ standard

License

MIT + file LICENSE

License flags

SPDX valid, OSI approved

History

Versions

7

First release

2023-11-07

Latest release

2026-03-04

Avg cadence

147 days

Cold removal rate

100%

Dep drift

2

LOC over versions

v0.1: 1,298 LOCv0.3: 1,671 LOCv0.4: 2,422 LOCv0.5: 2,711 LOCv0.5.1: 2,709 LOCv0.6.0: 2,961 LOCv0.7.0: 3,000 LOC

Per-file churn detail lives in the source pipeline: https://github.com/r-observatory/cran-code-metrics.

Reverse Dependencies (1)

imports

Dependency Network

Dependencies Reverse dependencies ggplot2 h2o curl pander HMDA shapley

Version History

8 tracked
new 0.7.0 Mar 10, 2026
updated 0.7.0 ← 0.6.0 diff Mar 3, 2026
updated 0.6.0 ← 0.5.1 diff Feb 12, 2026
updated 0.5.1 ← 0.5 diff Sep 17, 2025
updated 0.5 ← 0.4 diff Mar 18, 2025
updated 0.4 ← 0.3 diff Oct 22, 2024
updated 0.3 ← 0.1 diff May 29, 2024
new 0.1 Nov 6, 2023