Skip to content
This repository was archived by the owner on Sep 24, 2025. It is now read-only.
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
7 changes: 4 additions & 3 deletions ocean/cp/_explanation.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@


class Explanation(Mapper[FeatureVar], BaseExplanation):
_epsilon: float = 1e-3
_epsilon: float = 1e-6
_x: Array1D = np.zeros((0,), dtype=int)

def vget(self, i: int) -> cp.IntVar:
Expand Down Expand Up @@ -73,6 +73,7 @@ def get(v: FeatureVar) -> Key | Number:
return self.reduce(get)

def format_value(self, f: int, idx: int, levels: list[float]) -> float:
eps = min(self._epsilon, 0.5 * min(np.diff(levels)))
if self.query.shape[0] == 0:
return float(levels[idx] + levels[idx + 1]) / 2
j = 0
Expand All @@ -82,9 +83,9 @@ def format_value(self, f: int, idx: int, levels: list[float]) -> float:
if j == idx:
value = float(query_arr[f])
elif j < idx:
value = float(levels[idx]) + self._epsilon
value = float(levels[idx]) + eps
else:
value = float(levels[idx + 1]) - self._epsilon
value = float(levels[idx + 1]) - eps
return value

@property
Expand Down