Package: shapr 1.1.0

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.1.0.tar.gz
shapr_1.1.0.zip(r-4.7-x86_64)shapr_1.1.0.zip(r-4.7-arm64)shapr_1.1.0.zip(r-4.6-x86_64)shapr_1.1.0.zip(r-4.6-arm64)shapr_1.1.0.zip(r-4.5-x86_64)
shapr_1.1.0.tgz(r-4.6-x86_64)shapr_1.1.0.tgz(r-4.6-arm64)shapr_1.1.0.tgz(r-4.5-x86_64)shapr_1.1.0.tgz(r-4.5-arm64)
shapr_1.1.0.tar.gz(r-4.7-arm64)shapr_1.1.0.tar.gz(r-4.7-x86_64)shapr_1.1.0.tar.gz(r-4.6-arm64)shapr_1.1.0.tar.gz(r-4.6-x86_64)
shapr_1.1.0.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.65 score 178 stars 369 scripts 1.5k downloads 41 exports 14 dependencies

Last updated from:54bc95e45d. Checks:15 OK. Indexed: yes.

TargetResultTimeFilesSyslog
linux-devel-arm64OK325
linux-devel-x86_64OK438
source / vignettesOK313
linux-release-arm64OK319
linux-release-x86_64OK402
macos-release-arm64OK327
macos-release-x86_64OK968
macos-oldrel-arm64OK289
macos-oldrel-x86_64OK504
windows-devel-arm64OK452
windows-devel-x86_64OK408
windows-release-arm64OK445
windows-release-x86_64OK392
windows-oldrel-x86_64OK379
wasm-releaseOK154

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

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-09-14
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-09-14
Started: 2024-12-23

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-09-14
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 | Choosing a conditional approach | MSEv evaluation criterion | Advantage: | Disadvantages: | Confidence intervals | MSEv examples | Iterative estimation | Summary, Printing, and Result Extraction | SAGE: global feature importance | 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-09-14
Started: 2024-12-23