Define coalitions, and fetch additional information about each unique coalition
create_coalition_table(
m,
exact = TRUE,
n_coalitions = 200,
weight_zero_m = 10^6,
paired_shap_sampling = TRUE,
prev_coal_samples = NULL,
prev_coal_samples_n_unique = NULL,
n_samps_scale = 10,
coal_feature_list = as.list(seq_len(m)),
approach0 = "gaussian",
kernelSHAP_reweighting = "none",
dt_valid_causal_coalitions = NULL
)
A data.table with info about the coalitions to use
Positive integer. Total number of features/groups.
Logical.
If TRUE
all 2^m
coalitions are generated, otherwise a subsample of the coalitions is used.
Positive integer.
Note that if exact = TRUE
, n_coalitions
is ignored.
Numeric. The value to use as a replacement for infinite coalition weights when doing numerical operations.
Logical. Whether to do paired sampling of coalitions.
Character vector. A vector of previously sampled coalitions as characters. Each string contains a coalition and the feature indices in the coalition is separated by a space. For example, "1 5 8" is a coalition with features 1, 5, and 8.
Positive integer.
The number of unique coalitions in prev_coal_samples
.
This is a separate argument to avoid recomputing the number unnecessarily.
Positive integer.
Integer that scales the number of coalitions n_coalitions
to sample as sampling is cheap,
while checking for n_coalitions
unique coalitions is expensive, thus we over sample the
number of coalitions by a factor of n_samps_scale
and determine when we have n_coalitions
unique
coalitions and only use the coalitions up to this point and throw away the remaining coalitions.
List. A list mapping each coalition to the features it contains.
Character vector.
Contains the approach to be used for estimation of each coalition size. Same as approach
in explain()
.
data.table. Only applicable for asymmetric Shapley
values explanations, and is NULL
for symmetric Shapley values.
The data.table contains information about the coalitions that respects the causal ordering.
Nikolai Sellereite, Martin Jullum, Lars Henry Berge Olsen
if (FALSE) {
# All coalitions
x <- create_coalition_table(m = 3)
nrow(x) # Equals 2^3 = 8
# Subsample of coalitions
x <- shapr:::create_coalition_table(m = 10, exact = FALSE, n_coalitions = 1e2)
}
Run the code above in your browser using DataLab