Skip to content

Commit

Permalink
fix for one-sided experiment neutral value
Browse files Browse the repository at this point in the history
  • Loading branch information
egpbos committed Mar 5, 2024
1 parent 38db191 commit 39433b5
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/distance_explainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 39433b5

Please sign in to comment.