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

Mprt metrics #312

Merged
merged 2 commits into from
Nov 24, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions quantus/metrics/randomisation/smooth_mprt.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
# You should have received a copy of the GNU Lesser General Public License along with Quantus. If not, see <https://www.gnu.org/licenses/>.
# Quantus project URL: <https://github.com/understandable-machine-intelligence-lab/Quantus>.

import sys
import warnings
from typing import (
Any,
Expand Down Expand Up @@ -499,14 +498,15 @@ def evaluate_instance(

try:
return self.similarity_func(a_perturbed_flat, a_flat)
except stats._warnings_errors.ConstantInputWarning:
except Exception as e:
print(f"Encountered exception: {e} in similarity measure calculation")
warnings.warn(
"Encountered constant input in similarity measure calculation.",
"Setting similarity output to 1.",
UserWarning,
)
return 1.0

# Compute similarity measure.
# Compute similarity measure.
return self.similarity_func(a_perturbed_flat, a_flat)

def custom_preprocess(
Expand Down
Loading