igc.bsc.BaselineShapley#
- class igc.bsc.BaselineShapley(module, dataset, dtld_kwargs=None, forward_method_name=None, forward_method_kwargs=None, dtype=torch.float32, dtype_cat=torch.int32)[source]#
Bases:
AbstractAttributionMethod
Baseline Shapley (BS).
See the original paper [SN20] for more information.
- add_embedding_method(embedding_method_name, embedding_method_kwargs=None, embedding_n_cat=None)[source]#
Add an embedding method to preprocess categorical inputs.
Warning
This effect of this method must not excluded from the forward method defined by
forward_method_name
at initialization.- Parameters:
embedding_method_name (str) – Name of the embedding method of the
module
.embedding_method_kwargs (dict) – Additional keyword arguments to the embedding method of the
module
.embedding_n_cat (int) – Number of categorical inputs. If
None
, this value is inferred from the input data types (torch.int16
,torch.int32
,torch.int64
).
- Return type:
self
- compute(x, x_0=None, y_idx=None, n_iter=8, x_0_batch_size=1, x_seed=None, x_0_seed=100, check_error=True)[source]#
Compute Baseline Shapley (BS).
Warning
Baseline Shapley (BS) does not support multiple inputs.
- Parameters:
x (None | int | ArrayLike)
x_0 (None | int | float | ArrayLike)
y_idx (None | int | ArrayLike)
n_iter (int)
x_0_batch_size (int)
x_seed (None | int)
x_0_seed (None | int)
check_error (bool)
- Return type:
tuple(ArrayLike)