Measures the fraction of features assigned zero attribution that nonetheless change the model output when perturbed (axiomatic property: zero-attribution features should not matter). ↓ better.

non_sensitivity

non_sensitivity(
    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]

Fraction of zero-attribution features that nonetheless cause a model output change. ↓ better.

Alias for the second return value of monotonicity_corr_and_non_sens. See that function for full argument documentation.

Source code in torchxai/metrics/axiomatic/monotonicity_corr_and_non_sens.py
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
def non_sensitivity(
    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[torch.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-5,
    zero_variance_threshold: float = 1e-5,
    use_percentage_attribution_threshold: bool = False,
    return_ratio: bool = True,
    show_progress: bool = True,
    multi_target: bool = False,
) -> torch.Tensor | list[torch.Tensor]:
    """Fraction of zero-attribution features that nonetheless cause a model output change. ↓ better.

    Alias for the second return value of `monotonicity_corr_and_non_sens`. See that function for full
    argument documentation.
    """
    result = monotonicity_corr_and_non_sens(
        forward_func=forward_func,
        inputs=inputs,
        attributions=attributions,
        baselines=baselines,
        feature_mask=feature_mask,
        additional_forward_args=additional_forward_args,
        target=target,
        frozen_features=frozen_features,
        perturb_func=perturb_func,
        n_perturbations_per_feature=n_perturbations_per_feature,
        max_features_processed_per_batch=max_features_processed_per_batch,
        percentage_feature_removal_per_step=percentage_feature_removal_per_step,
        zero_attribution_threshold=zero_attribution_threshold,
        zero_variance_threshold=zero_variance_threshold,
        use_percentage_attribution_threshold=use_percentage_attribution_threshold,
        return_ratio=return_ratio,
        show_progress=show_progress,
        multi_target=multi_target,
    )
    return result[1]