Skip to content

Commit

Permalink
Merge pull request #59 from fzi-forschungszentrum-informatik/LEFTIST
Browse files Browse the repository at this point in the history
Leftist
  • Loading branch information
JHoelli authored Feb 26, 2024
2 parents 7437fbd + f36037f commit b576faf
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 31 deletions.
Binary file modified ClassificationModels/models/ElectricDevices/OneHotEncoder.pkl
Binary file not shown.
Binary file modified ClassificationModels/models/GunPoint/OneHotEncoder.pkl
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def __init__(
data,
backend="PYT",
mode="feat",
method="NUN-CF",
method="NUN_CF",
distance_measure="dtw",
n_neighbors=1,
max_iter=500,
Expand Down
22 changes: 17 additions & 5 deletions TSInterpret/InterpretabilityModels/leftist/leftist.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,22 +168,34 @@ def explain(
self.neighbors, idx_label, explanation_size=explanation_size
)
]
#print(idx_label)
#print('Final')
#print(explanations)
#print(instance)
explanations = self._shape_explanations(explanations, instance)

return explanations

def _shape_explanations(self, explanations, series):
values_per_slice = int(len(series) / len(explanations[0][0]))

values_per_slice =self.nb_interpretable_feature #int(len(series) / len(explanations[0][0]))
heatmaps = []
i = 0
for i in range(0, len(explanations)):

heatmap = np.zeros_like(series).reshape(-1)
j=0
for value in explanations[i][0]:
heatmap[i : values_per_slice + i] = (
np.ones_like(values_per_slice) * value
)
i = values_per_slice + i
try:
heatmap[j : values_per_slice + j] = (
np.ones_like(values_per_slice) * value
)
except:
heatmap[j : ] = (
np.ones_like(heatmap[j : ]) * value
)

j = values_per_slice + j
heatmaps.append(heatmap)

return heatmaps
2 changes: 1 addition & 1 deletion TSInterpret/__version__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
VERSION = (0, 4, 2)
VERSION = (0, 4, 3)
__version__ = ".".join(map(str, VERSION)) # noqa: F401
58 changes: 34 additions & 24 deletions docs/Notebooks/Leftist_torch.ipynb

Large diffs are not rendered by default.

0 comments on commit b576faf

Please sign in to comment.