Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Default normalisation function #48

Closed
leanderweber opened this issue Jan 19, 2022 · 1 comment
Closed

Default normalisation function #48

leanderweber opened this issue Jan 19, 2022 · 1 comment

Comments

@leanderweber
Copy link
Collaborator

leanderweber commented Jan 19, 2022

For a lot of quantification metrics (only checked the faithfulness_metrics.py for this) the default seems to be

self.normalise = self.kwargs.get("normalise", True)
self.normalise_func` = self.kwargs.get("normalise_func", normalise_by_negative)

with normalise_by_negative being defined in normalise_func.py as

def normalise_by_negative(a: np.ndarray) -> np.ndarray:
    """Normalise relevance given a relevance matrix (r) [-1, 1]."""
    if a.min() >= 0.0:
        return a / a.max()
    if a.max() <= 0.0:
        return -a / a.min()
    return (a > 0.0) * a / a.max() - (a < 0.0) * a / a.min()

I think this type of normalisation (as default) may lead to some unexpected/unintended behavior for many metrics (RegionPerturbation, for instance), since it normalises positive and negative parts of an attribution map by different values, and then changes the sign of the negative parts (thus basically taking the abs()). I believe this changes not only the ordering of attribution values (as abs() would), but also their relative magnitudes.

For this reason, a better default may be either self.normalise = self.kwargs.get("normalise", False) or self.normalise_func = self.kwargs.get("normalise_func", normalise_by_max)` ?

@leanderweber
Copy link
Collaborator Author

nvm, missed the sign of the negatives

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant