Spearman rank correlation between feature attribution magnitudes and the change in model output when each feature is perturbed. High correlation indicates that more-important features (by attribution) actually have larger impact on the output. ↑ better.
monotonicity_corr
monotonicity_corr(
forward_func: Callable,
inputs: TensorOrTupleOfTensorsGeneric,
attributions: list[TensorOrTupleOfTensorsGeneric] | TensorOrTupleOfTensorsGeneric,
baselines: BaselineType = None,
feature_mask: TensorOrTupleOfTensorsGeneric | None = None,
additional_forward_args: Any = None,
target: ExplanationTarget | list[ExplanationTarget] = NoTarget(),
frozen_features: list[Tensor] | None = None,
perturb_func: Callable = default_fixed_baseline_perturb_func(),
n_perturbations_per_feature: int = 10,
max_features_processed_per_batch: int | None = None,
percentage_feature_removal_per_step: float = 0.0,
zero_attribution_threshold: float = 1e-05,
zero_variance_threshold: float = 1e-05,
use_percentage_attribution_threshold: bool = False,
return_ratio: bool = True,
show_progress: bool = True,
multi_target: bool = False,
) -> Tensor | list[Tensor]
Spearman correlation between attribution magnitudes and output variance under unordered perturbations. ↑ better.
Faithfulness metric: measures whether features with higher attribution magnitudes actually produce
larger changes in model output when perturbed. Alias for the first return value of
monotonicity_corr_and_non_sens. See that function for full argument documentation.
Source code in torchxai/metrics/faithfulness/monotonicity_corr.py
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 | |