xai4tsc.evaluation.quantus_groups
What each Quantus metric consumes, and the explanation domains that follow from it.
Quantus metrics do not all need the same inputs. A metric that reads only the
attribution measures a property of the attribution itself and is therefore
domain-agnostic; one that perturbs the input and re-queries the model needs the
explanation in the model-native domain, the domain the model’s inputs live in
(Explanation.data_domain), because that is the space it can perturb and predict
in. For a model trained on raw series that is the time domain; for one trained on
spectra it is the frequency domain, and these metrics apply there instead. Quantus
itself draws no such distinction - every metric inherits one __call__ that
asserts the attribution and the input correspond - so it is recorded here.
The four groups are disjoint and cover every key of QUANTUS_METRICS:
group |
its own code reads |
n |
explanation domain |
|---|---|---|---|
|
|
3 |
any |
|
|
16 |
model-native |
|
|
6 |
model-native (see below) |
|
|
12 |
model-native |
Derived by walking each metric’s own evaluate_batch / evaluate_instance /
custom_*_preprocess bodies with ast, excluding the inherited
Metric.__call__ that every subclass re-declares with the full parameter list.
sandbox/fixtures/group_metrics.py re-derives the table from the installed
quantus so it can be re-checked after a dependency bump.
LOCALISATION is model-native for the time being because it is blocked on
s_batch (ground-truth masks), which nothing supplies yet - not because of the
domain. Once masks are derived, those six become domain-agnostic too:
TimeFrequencyAUCEvaluator already
builds ground-truth masks on the coefficient grid.
Attributes
Group of every metric in |
|
Metrics whose Quantus implementation cannot serve a time series correctly. |
Classes
Which inputs a Quantus metric's own code reads; see the module docstring. |
Functions
|
Return whether the named Quantus metric needs the model-native domain. |
|
Return whether the named Quantus metric re-explains and so needs an explain func. |
|
Return whether the named Quantus metric scores against ground-truth masks. |
Module Contents
- class xai4tsc.evaluation.quantus_groups.QuantusGroup(*args, **kwds)
Bases:
enum.EnumWhich inputs a Quantus metric’s own code reads; see the module docstring.
- ATTRIBUTION_ONLY = 'attribution-only'
Reads the attribution alone, so it applies in any explanation domain.
- MODEL_PERTURBATION = 'model-perturbation'
Perturbs the input and re-queries the model.
- LOCALISATION = 'localisation'
Scores the attribution against a ground-truth mask (
s_batch).
- RE_EXPLAIN = 're-explain'
Re-explains perturbed or randomised inputs via
explain_func.
- xai4tsc.evaluation.quantus_groups.QUANTUS_GROUPS: dict[str, QuantusGroup]
Group of every metric in
QUANTUS_METRICS, keyed by the same display name.
- xai4tsc.evaluation.quantus_groups.quantus_requires_native_domain(name: str) bool
Return whether the named Quantus metric needs the model-native domain.
- Parameters:
name (str) – A key of
QUANTUS_METRICS(the metric’s display name).- Returns:
Trueif the explanation must be in the same domain as the model’s inputs,Falseif the metric applies in any domain. An unclassified name is treated as needing the native domain, the conservative choice.- Return type:
bool
- xai4tsc.evaluation.quantus_groups.quantus_requires_explain_func(name: str) bool
Return whether the named Quantus metric re-explains and so needs an explain func.
- Parameters:
name (str) – A key of
QUANTUS_METRICS(the metric’s display name).- Returns:
Truefor theRE_EXPLAINgroup only. An unclassified name is treated as not requiring one: supplying the callable to a metric that ignores it is harmless, whereas demanding one that is never used would refuse a metric that works.- Return type:
bool
- xai4tsc.evaluation.quantus_groups.quantus_requires_s_batch(name: str) bool
Return whether the named Quantus metric scores against ground-truth masks.
- Parameters:
name (str) – A key of
QUANTUS_METRICS(the metric’s display name).- Returns:
Truefor theLOCALISATIONgroup only. These metrics compare the attribution against the region a dataset declares as discriminative, so they are unusable without one — unlike the other groups, which need nothing but the model and the attribution.- Return type:
bool
- xai4tsc.evaluation.quantus_groups.BLOCKED_BY_BACKEND: dict[str, str]
Metrics whose Quantus implementation cannot serve a time series correctly.
Four of them index a second spatial axis that a
(B, C, T)series does not have - super-pixels, quadrants, 2-D padding, pixel neighbourhoods - and raise somewhere inside the library. Refusing them here turns an obscureIndexErroror shape assertion into a stated reason, and keeps them out of the error column where they look like something worth fixing.Smooth MPRTis the dangerous one and the reason this table is not just about shapes: it returns a number. It calls the library’s own explain function instead of the one it is given, so without this entry it would report a plausible score for an explainer it never ran.