shapr1.0.3 package

Prediction Explanation with Dependence-Aware Shapley Values

additional_regression_setup

Additional setup for regression-based methods

aicc_full_cpp

AICc formula for several sets, alternative definition

aicc_full_single_cpp

Temp-function for computing the full AICc with several X's etc

append_vS_list

Appends the new vS_list to the prev vS_list

categorical_to_one_hot_layer

A torch::nn_module() Representing a categorical_to_one_hot_layer

check_categorical_valid_MCsamp

Check that all explicands has at least one valid MC sample in causal S...

check_convergence

Checks the convergence according to the convergence threshold

check_groups

Check that the group parameter has the right form and content

check_verbose

Function that checks the verbose parameter

cli_compute_vS

Printing messages in compute_vS with cli

cli_iter

Printing messages in iterative procedure with cli

cli_startup

Printing startup messages with cli

coalition_matrix_cpp

Get coalition matrix

compute_estimates

Computes the the Shapley values and their standard deviation given the...

compute_MSEv_eval_crit

Mean Squared Error of the Contribution Function v(S)

compute_shapley

Compute shapley values

compute_time

Gathers and computes the timing of the different parts of the explain ...

compute_vS

Computes v(S) for all features subsets S.

convert_feature_name_to_idx

Convert feature names into feature indices

correction_matrix_cpp

Correction term with trace_input in AICc formula

create_coalition_table

Define coalitions, and fetch additional information about each unique ...

create_ctree

Build all the conditional inference trees

create_marginal_data_cat

Create marginal categorical data for causal Shapley values

create_marginal_data_gaussian

Generate marginal Gaussian data using Cholesky decomposition

create_marginal_data_training

Function that samples data from the empirical marginal training distri...

default_doc_export

Exported documentation helper function.

default_doc_internal

Unexported documentation helper function.

exact_coalition_table

Get table with all (exact) coalitions

explain_forecast

Explain a forecast from time series models with dependence-aware (cond...

explain

Explain the output of machine learning models with dependence-aware (c...

finalize_explanation

Gathers the final output to create the explanation object

gauss_cat_loss

A torch::nn_module() Representing a gauss_cat_loss

gauss_cat_parameters

A torch::nn_module() Representing a gauss_cat_parameters

gauss_cat_sampler_most_likely

A torch::nn_module() Representing a gauss_cat_sampler_most_likely

gauss_cat_sampler_random

A torch::nn_module() Representing a gauss_cat_sampler_random

gaussian_transform_separate

Transforms new data to standardized normal (dimension 1) based on othe...

gaussian_transform

Transforms a sample to standardized normal distribution

get_cov_mat

get_cov_mat

get_data_forecast

Set up data for explain_forecast

get_data_specs

Fetches feature information from a given data set

get_extra_comp_args_default

Gets the default values for the extra computation arguments

get_extra_parameters

This includes both extra parameters and other objects

get_feature_specs

Gets the feature specifications form the model

get_iterative_args_default

Function to specify arguments of the iterative estimation procedure

get_max_n_coalitions_causal

Get the number of coalitions that respects the causal ordering

get_model_specs

Fetches feature information from natively supported models

get_mu_vec

get_mu_vec

get_output_args_default

Gets the default values for the output arguments

get_predict_model

Get predict_model function

get_S_causal_steps

Get the steps for generating MC samples for coalitions following a cau...

get_supported_approaches

Gets the implemented approaches

get_supported_models

Provides a data.table with the supported models

get_valid_causal_coalitions

Get all coalitions satisfying the causal ordering

group_forecast_setup

Set up user provided groups for explanation in a forecast model.

hat_matrix_cpp

Computing single H matrix in AICc-function using the Mahalanobis dista...

inv_gaussian_transform_cpp

Transforms new data to a standardized normal distribution

lag_data

Lag a matrix of variables a specific number of lags for each variables...

mahalanobis_distance_cpp

(Generalized) Mahalanobis distance

mcar_mask_generator

Missing Completely at Random (MCAR) Mask Generator

memory_layer

A torch::nn_module() Representing a Memory Layer

model_checker

Check that the type of model is supported by the native implementation...

observation_impute_cpp

Get imputed data

observation_impute

Generate permutations of training data using test observations

paired_sampler

Sampling Paired Observations

plot_MSEv_eval_crit

Plots of the MSEv Evaluation Criterion

plot_SV_several_approaches

Shapley value bar plots for several explanation objects

plot_vaeac_eval_crit

Plot the training VLB and validation IWAE for vaeac models

plot_vaeac_imputed_ggpairs

Plot Pairwise Plots for Imputed and True Data

plot.shapr

Plot of the Shapley value explanations

predict_model

Generate predictions for input data with specified model

prepare_data_causal

Generate data used for predictions and Monte Carlo integration for cau...

prepare_data_copula_cpp_caus

Generate (Gaussian) Copula MC samples for the causal setup with a sing...

prepare_data_copula_cpp

Generate (Gaussian) Copula MC samples

prepare_data_gaussian_cpp_caus

Generate Gaussian MC samples for the causal setup with a single MC sam...

prepare_data_gaussian_cpp

Generate Gaussian MC samples

prepare_data_single_coalition

Compute the conditional probabilities for a single coalition for the c...

prepare_data

Generate data used for predictions and Monte Carlo integration

prepare_next_iteration

Prepares the next iteration of the iterative sampling algorithm

print_iter

Prints iterative information

print.shapr

Print method for shapr objects

process_factor_data

Treat factors as numeric values

quantile_type7_cpp

Compute the quantiles using quantile type seven

reg_forecast_setup

Set up exogenous regressors for explanation in a forecast model.

regression.check_namespaces

Check that needed libraries are installed

regression.check_parameters

Check regression parameters

regression.check_recipe_func

Check regression.recipe_func

regression.check_sur_n_comb

Check the regression.surrogate_n_comb parameter

regression.check_vfold_cv_para

Check the parameters that are sent to rsample::vfold_cv()

regression.cv_message

Produce message about which batch prepare_data is working on

regression.get_string_to_R

Convert the string into an R object

regression.get_tune

Get if model is to be tuned

regression.get_y_hat

Get the predicted responses

regression.surrogate_aug_data

Augment the training data and the explicands

regression.train_model

Train a tidymodels model via workflows

release_questions

Auxiliary function for the vignettes

rss_cpp

Function for computing sigma_hat_sq

sample_coalition_table

Get table with sampled coalitions

sample_coalitions_cpp_str_paired

We here return a vector of strings/characters, i.e., a CharacterVector...

sample_combinations

Helper function to sample a combination of training and testing rows, ...

sample_ctree

Sample ctree variables from a given conditional inference tree

save_results

Saves the intermediate results to disk

setup_approach

Set up the framework for the chosen approach

setup

check_setup

shapley_setup

Set up the kernelSHAP framework

shapley_weights

Calculate Shapley weight

shapr-package

shapr: Prediction Explanation with Dependence-Aware Shapley Values

skip_connection

A torch::nn_module() Representing a skip connection

specified_masks_mask_generator

A torch::nn_module() Representing a specified_masks_mask_generator

specified_prob_mask_generator

A torch::nn_module() Representing a specified_prob_mask_generator

test_predict_model

Model testing function

testing_cleanup

Cleans out certain output arguments to allow perfect reproducibility o...

vaeac_categorical_parse_params

Creates Categorical Distributions

vaeac_check_activation_func

Function that checks the provided activation function

vaeac_check_cuda

Function that checks for access to CUDA

vaeac_check_epoch_values

Function that checks provided epoch arguments

vaeac_check_extra_named_list

Check vaeac.extra_parameters list

vaeac_check_logicals

Function that checks logicals

vaeac_check_mask_gen

Function that checks the specified masking scheme

vaeac_check_masking_ratio

Function that checks that the masking ratio argument is valid

vaeac_check_parameters

Function that calls all vaeac parameters check functions

vaeac_check_positive_integers

Function that checks positive integers

vaeac_check_positive_numerics

Function that checks positive numerics

vaeac_check_probabilities

Function that checks probabilities

vaeac_check_save_names

Function that checks that the save folder exists and for a valid file ...

vaeac_check_save_parameters

Function that gives a warning about disk usage

vaeac_check_which_vaeac_model

Function that checks for valid vaeac model name

vaeac_check_x_colnames

Function that checks the feature names of data and vaeac model

vaeac_compute_normalization

Compute Featurewise Means and Standard Deviations

vaeac_dataset

Dataset used by the vaeac model

vaeac_extend_batch

Extends Incomplete Batches by Sampling Extra Data from Dataloader

vaeac_get_current_save_state

Function that extracts additional objects from the environment to the ...

vaeac_get_data_objects

Function to set up data loaders and save file names

vaeac_get_evaluation_criteria

Extract the Training VLB and Validation IWAE from a list of explanatio...

vaeac_get_extra_para_default

Function to specify the extra parameters in the vaeac model

vaeac_get_full_state_list

Function that extracts the state list objects from the environment

vaeac_get_mask_generator_name

Function that determines which mask generator to use

vaeac_get_model_from_checkp

Function to load a vaeac model and set it in the right state and mod...

vaeac_get_n_decimals

Function to get string of values with specific number of decimals

vaeac_get_optimizer

Function to create the optimizer used to train vaeac

vaeac_get_save_file_names

Function that creates the save file names for the vaeac model

vaeac_get_val_iwae

Compute the Importance Sampling Estimator (Validation Error)

vaeac_get_x_explain_extended

Function to extend the explicands and apply all relevant masks/coaliti...

vaeac_impute_missing_entries

Impute Missing Values Using Vaeac

vaeac_kl_normal_normal

Compute the KL Divergence Between Two Gaussian Distributions.

vaeac_normal_parse_params

Creates Normal Distributions

vaeac_normalize_data

Normalize mixed data for vaeac

vaeac_postprocess_data

Postprocess Data Generated by a vaeac Model

vaeac_preprocess_data

Preprocess Data for the vaeac approach

vaeac_print_train_summary

Function to printout a training summary for the vaeac model

vaeac_save_state

Function that saves the state list and the current save state of the `...

vaeac_train_model_auxiliary

Function used to train a vaeac model

vaeac_train_model_continue

Continue to Train the vaeac Model

vaeac_train_model

Train the Vaeac Model

vaeac_update_para_locations

Move vaeac parameters to correct location

vaeac_update_pretrained_model

Function that checks and adds a pre-trained vaeac model

vaeac

Initializing a vaeac model

weight_matrix_cpp

Calculate weight matrix

weight_matrix

Calculate weighted matrix

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 ('shaprpy') is available through the GitHub repository.

  • Maintainer: Martin Jullum
  • License: MIT + file LICENSE
  • Last published: 2025-03-26