Skip to content

Commit

Permalink
Merge branch 'ilmat/fix-sparse-order' of https://github.com/imatiach-…
Browse files Browse the repository at this point in the history
…msft/lime into imatiach-msft-ilmat/fix-sparse-order
  • Loading branch information
marcotcr committed Jul 2, 2019
2 parents fde6867 + 0441ac7 commit 080f9ec
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions lime/lime_tabular.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,17 @@ def visualize_instance_html(self,
# Sparse case: only display the non-zero values and importances
fnames = [self.exp_feature_names[i] for i in self.feature_indexes]
fweights = [weights[i] for i in self.feature_indexes]
out_list = list(zip(fnames,
self.feature_values,
fweights))
if not show_all:
out_list = [x for x in out_list if x[2] != 0]
if show_all:
out_list = list(zip(fnames,
self.feature_values,
fweights))
else:
out_dict = dict(map(lambda x: (x[0], (x[1], x[2], x[3])),
zip(self.feature_indexes,
fnames,
self.feature_values,
fweights)))
out_list = [out_dict.get(x[0], (str(x[0]), 0.0, 0.0)) for x in exp]
else:
out_list = list(zip(self.exp_feature_names,
self.feature_values,
Expand Down

0 comments on commit 080f9ec

Please sign in to comment.