Skip to content

Instantly share code, notes, and snippets.

@edunuke
Last active November 17, 2018 21:00
Show Gist options
  • Select an option

  • Save edunuke/a86d8b4971762095f50ffeb4bb176e5f to your computer and use it in GitHub Desktop.

Select an option

Save edunuke/a86d8b4971762095f50ffeb4bb176e5f to your computer and use it in GitHub Desktop.
from lime import submodular_pick
#set up sp lime with 20 samples. The more amount of samples time increases dramatically
sp_obj = submodular_pick.SubmodularPick(explainer,
X_train.values[:500],
predict,
sample_size=20,
num_features=9,
num_exps_desired=5)
#get explanation matrix
W_matrix = pd.DataFrame([dict(this.as_list()) for this in sp_obj.explanations])
#get overall mean explanation for each feature
matrix_mean = W_matrix.mean()
plt.figure(figsize=(14,6))
matrix_mean.sort_values(ascending=False).plot.bar()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment