Package: shapr 1.0.8.9001

Martin Jullum

shapr: Prediction Explanation with Dependence-Aware Shapley Values

Complex machine learning models are often hard to interpret. However, in many situations it is crucial to understand and explain why a model made a specific prediction. Shapley values is the only method for such prediction explanation framework with a solid theoretical foundation. Previously known methods for estimating the Shapley values do, however, assume feature independence. This package implements methods which accounts for any feature dependence, and thereby produces more accurate estimates of the true Shapley values. An accompanying 'Python' wrapper ('pyshapr') is available through PyPI.

Authors:Martin Jullum [cre, aut], Lars Henry Berge Olsen [aut], Annabelle Redelmeier [aut], Jon Lachmann [aut], Nikolai Sellereite [aut], Anders Løland [ctb], Jens Christian Wahl [ctb], Camilla Lingjærde [ctb], Norsk Regnesentral [cph, fnd]

shapr_1.0.8.9001.tar.gz
shapr_1.0.8.9001.zip(r-4.7)shapr_1.0.8.9001.zip(r-4.6)shapr_1.0.8.9001.zip(r-4.5)
shapr_1.0.8.9001.tgz(r-4.6-x86_64)shapr_1.0.8.9001.tgz(r-4.6-arm64)shapr_1.0.8.9001.tgz(r-4.5-x86_64)shapr_1.0.8.9001.tgz(r-4.5-arm64)
shapr_1.0.8.9001.tar.gz(r-4.7-arm64)shapr_1.0.8.9001.tar.gz(r-4.7-x86_64)shapr_1.0.8.9001.tar.gz(r-4.6-arm64)shapr_1.0.8.9001.tar.gz(r-4.6-x86_64)
shapr_1.0.8.9001.tgz(r-4.6-emscripten)
manual.pdf |manual.html
DESCRIPTION |NEWS
card.svg |card.png
shapr/json (API)

# Install 'shapr' in R:
install.packages('shapr', repos = c('https://norskregnesentral.r-universe.dev', 'https://cloud.r-project.org'))

Bug tracker:https://github.com/norskregnesentral/shapr/issues

Pkgdown/docs site:https://norskregnesentral.github.io

Uses libs:
  • openblas– Optimized BLAS
  • c++– GNU Standard C++ Library v3
  • openmp– GCC OpenMP (GOMP) support library

On CRAN:

Conda:

explainable-aiexplainable-mlrcpprcpparmadilloshapleyopenblascppopenmp

10.54 score 177 stars 366 scripts 1.7k downloads 41 exports 14 dependencies

Last updated from:2689d24d86. Checks:13 OK. Indexed: yes.

TargetResultTimeFilesSyslog
linux-devel-arm64OK372
linux-devel-x86_64OK410
source / vignettesOK327
linux-release-arm64OK380
linux-release-x86_64OK365
macos-release-arm64OK293
macos-release-x86_64OK603
macos-oldrel-arm64OK228
macos-oldrel-x86_64OK608
windows-develOK406
windows-releaseOK366
windows-oldrelOK522
wasm-releaseOK224

Exports:additional_regression_setupappend_vS_listcheck_convergencecli_compute_vScli_itercli_startupcoalition_matrix_cppcompute_estimatescompute_shapleycompute_timecompute_vSexplainexplain_forecastfinalize_explanationget_extra_comp_args_defaultget_iterative_args_defaultget_model_specsget_output_args_defaultget_resultsget_supported_approachesget_supported_modelsplot_MSEv_eval_critplot_SV_several_approachesplot_vaeac_eval_critplot_vaeac_imputed_ggpairspredict_modelprepare_dataprepare_data_causalprepare_next_iterationprint_iterregression.train_modelsave_resultssetupsetup_approachshapley_setuptesting_cleanupvaeac_get_evaluation_criteriavaeac_get_extra_para_defaultvaeac_train_modelvaeac_train_model_continueweight_matrix

Dependencies:clicodetoolsdata.tabledigestfuturefuture.applyglobalslatticelistenvMatrixparallellyRcppRcppArmadillorlang

Shapley value explanations using the regression paradigm
The separate regression method class | Code | Setup | Linear regression model | Pre-processing | Other regression models | Cross-validation | Parallelization | The surrogate regression method class | Code | Parallelization | Add new regression methods | Summary figures | Mixed data | Mixed data: setup | Mixed data: Monte Carlo-based methods | Mixed data: separate regression methods | Mixed data: surrogate regression methods | Mixed data: summary | Regression arguments as strings | Summary | References

Last update: 2026-06-23
Started: 2024-12-23

shapr: Explaining individual machine learning predictions with Shapley values
Introduction | Overview of Package | Functionality | Default behavior of explain | Kernel SHAP and dependence-aware estimators | The Kernel SHAP Method | Multivariate Gaussian Distribution Approach | Gaussian Copula Approach | Empirical Conditional Distribution Approach | Conditional Inference Tree Approach | Adversarial Random Forest (arf) Approach | Variational AutoEncoder with Arbitrary Conditioning (vaeac) Approach | Categorical Approach | Separate and Surrogate Regression Approaches | Estimation approaches and plotting functionality | MSEv evaluation criterion | Advantage: | Disadvantages: | Confidence intervals | MSEv examples | Iterative estimation | Summary, Printing, and Result Extraction | Parallelization | Batch computation | Parallelized computation | Verbosity and progress updates | Advanced usage | Combined approach | Explain groups of features | Explain custom models | Tidymodels and workflows | The parameters of the vaeac approach | Early stopping | Continued computation | Explaining a forecasting model using explain_forecast | References

Last update: 2026-06-17
Started: 2024-12-23

Asymmetric and causal Shapley value explanations
Overview | Asymmetric conditional Shapley values | Causal Shapley values | Marginal Shapley values | Symmetric conditional Shapley values | Code example | Overview | Code setup | Symmetric conditional Shapley values (default) | Asymmetric conditional Shapley values | Symmetric marginal Shapley values | Causal Shapley values | Symmetric | Asymmetric | Comparing the frameworks | Scatter plots: marginal vs. causal Shapley values | Investigating two similar days | Sampling of coalitions | Groups of features | Implementation details | References

Last update: 2026-06-17
Started: 2024-12-23

More details and advanced usage of the vaeac approach
Vaeac | Code Examples | Basic Example | First vaeac example | Pre-trained vaeac | Pre-trained vaeac (path) | Specified max_n_coalitions | Paired sampling | Progressr | Continue the training of the vaeac approach | Vaeac with early stopping | Grouping of features | Mixed Data

Last update: 2026-06-09
Started: 2024-12-23