Skip to content

Commit

Permalink
Merge branch 'imatiach-msft-ilmat/fix-sparse-order'
Browse files Browse the repository at this point in the history
  • Loading branch information
marcotcr committed Jul 2, 2019
2 parents fde6867 + 080f9ec commit 8d8ebb7
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 8d8ebb7

Please sign in to comment.