From 39433b5d7a19b9d6ca710ecc42fa89e6370b242c Mon Sep 17 00:00:00 2001 From: "E. G. Patrick Bos" Date: Tue, 5 Mar 2024 14:41:32 +0100 Subject: [PATCH] fix for one-sided experiment neutral value --- src/distance_explainer.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/distance_explainer.py b/src/distance_explainer.py index ff0b43f..bd8d918 100644 --- a/src/distance_explainer.py +++ b/src/distance_explainer.py @@ -127,6 +127,14 @@ def describe(x, name): input_distance = DistanceExplainer.calculate_distances(input_prediction, embedded_reference) neutral_value = np.exp(-input_distance) + # for one-sided experiments, use "meaningful" neutral value (the unperturbed distance), otherwise center on 0 + if len(lowest_mask_weights) > 0 and len(highest_mask_weights) == 0: + neutral_value = neutral_value + if len(highest_mask_weights) > 0 and len(lowest_mask_weights) == 0: + neutral_value = -neutral_value + if len(highest_mask_weights) > 0 and len(lowest_mask_weights) > 0: + neutral_value = 0 + return saliency, neutral_value @staticmethod