igc.igac.IntGradAutoCorr#
- class igc.igac.IntGradAutoCorr(module, dataset=None, dtld_kwargs=None, forward_method_name=None, forward_method_kwargs=None, dtype=torch.float32, dtype_cat=torch.int32)[source]#
Bases:
IntegratedGradients
Integrated Gradient Auto-Correlation (IGaC).
See the original paper [LelievreC24] 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
- add_ig_post_function(ig_post_func, ig_post_func_kwargs=None)[source]#
Add a function to postprocess individual IG attributions.
Warning
The IG postprocessing function must have the following signature:
def ig_post(ig_x_1, ..., ig_x_n, x_1, ..., x_n, **kwargs) # Do something on IG data return ig_x_1, ..., ig_x_n
- Parameters:
ig_post_func (function) – Function to postprocess individual IG attributions.
ig_post_func_kwargs (dict) – Additional keyword arguments to the IG postprocessing function.
- Return type:
self
- compute(x_0=None, y_idx=None, n_steps=64, batch_size=None, x_seed=None, x_0_seed=100, n_x=None, check_error=True)[source]#
Compute Integrated Gradient Auto-Correlation (IGaC).
- Parameters:
x_0 (None | int | float | ArrayLike | tuple(ArrayLike))
y_idx (None | int | ArrayLike)
n_steps (int)
batch_size (int | tuple(int))
x_seed (None | int)
x_0_seed (None | int)
n_x (None | int)
check_error (bool)
- Return type:
ArrayLike | tuple(ArrayLike)