Skip to content

Instantly share code, notes, and snippets.

@crawles
Created March 5, 2019 02:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save crawles/075fdfb0d5cfbd963821be930d4e5561 to your computer and use it in GitHub Desktop.
Save crawles/075fdfb0d5cfbd963821be930d4e5561 to your computer and use it in GitHub Desktop.
# Make predictions.
pred_dicts = list(est.experimental_predict_with_explanations(eval_input_fn))
df_dfc = pd.DataFrame([pred['dfc'] for pred in pred_dicts])
# Plot results.
ID = 182
example = df_dfc.iloc[ID] # Choose ith example from evaluation set.
TOP_N = 8 # View top 8 features.
sorted_ix = example.abs().sort_values()[-TOP_N:].index
ax = example[sorted_ix].plot(kind='barh')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment