xai4tsc.xai.random_baseline
Random-baseline explainers in the frequency and time-frequency domains.
Sanity baselines for evaluation: they ignore the model and return uniform-random relevance shaped like the transformed input. A faithful explainer should beat these on perturbation metrics.
Classes
Uniform-random baseline relevance in the frequency domain. |
|
Uniform-random baseline relevance in the time-frequency domain. |
Module Contents
- class xai4tsc.xai.random_baseline.RandomFrequencyExplainer(transform: xai4tsc.utils.fourier_transforms.DomainTransform | dict | None = None, seed: int | None = None)
Bases:
xai4tsc.xai.base.PerturbationExplainerUniform-random baseline relevance in the frequency domain.
- Parameters:
transform (DomainTransform or dict, optional) – Transform from time to frequency domain. Defaults to a full
FourierTransform.seed (int, optional) – Seed for the random relevance, for reproducible draws.
- data_applicability: ClassVar[set[xai4tsc.xai._types.DataType]]
Data domains this explainer applies to. A set of
DataTypemembers —{DataType.AGNOSTIC}(any input) or{DataType.TIME_SERIES}.
- explanation_domains: ClassVar[set[xai4tsc.xai._types.Domain]]
Signal domains this explainer can produce explanations in. A set of
Domainmembers (capability declaration, mirroringdata_applicability). Checked statically by the runner’s config sanity check before any explainer is instantiated. Defaults to{Domain.TIME}; frequency/time-frequency explainers override it. The realized domain of a produced explanation (Explanation.explanation_domain) must be a member of this set.
- transform
- prng
- explain(model: torch.nn.Module, exp: xai4tsc.xai._types.Explanation, device: str | torch.device, targets: list | None, **kwargs: object) numpy.ndarray
Return uniform-random relevance shaped like the frequency transform.
- class xai4tsc.xai.random_baseline.RandomTimeFreqExplainer(transform: xai4tsc.utils.fourier_transforms.DomainTransform | dict | None = None, seed: int | None = None)
Bases:
xai4tsc.xai.base.PerturbationExplainerUniform-random baseline relevance in the time-frequency domain.
- Parameters:
transform (DomainTransform or dict) – Transform from time to time-frequency domain (e.g. an
STFTransform). Required — there is no sensible default window configuration.seed (int, optional) – Seed for the random relevance, for reproducible draws.
- data_applicability: ClassVar[set[xai4tsc.xai._types.DataType]]
Data domains this explainer applies to. A set of
DataTypemembers —{DataType.AGNOSTIC}(any input) or{DataType.TIME_SERIES}.
- explanation_domains: ClassVar[set[xai4tsc.xai._types.Domain]]
Signal domains this explainer can produce explanations in. A set of
Domainmembers (capability declaration, mirroringdata_applicability). Checked statically by the runner’s config sanity check before any explainer is instantiated. Defaults to{Domain.TIME}; frequency/time-frequency explainers override it. The realized domain of a produced explanation (Explanation.explanation_domain) must be a member of this set.
- transform = None
- prng
- explain(model: torch.nn.Module, exp: xai4tsc.xai._types.Explanation, device: str | torch.device, targets: list | None, **kwargs: object) numpy.ndarray
Return uniform-random relevance shaped like the time-frequency transform.