SHARE
TWEET

Untitled

a guest Apr 20th, 2019 76 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # %% markdown
  2. # WEER IMPACT
  3.  
  4. # %%
  5. # SETUP
  6. import pandas as pd
  7. import numpy as np
  8. import pickle
  9. import matplotlib
  10. import matplotlib.pyplot as plt
  11. import shap
  12. shap.initjs()
  13.  
  14. # %%
  15. # DATA
  16. pickle_in = open('booster.pickle', 'rb')
  17. booster = pickle.load(pickle_in) # Load XGBoost booster object
  18.  
  19. pickle_in = open('features.pickle', 'rb')
  20. features = pickle.load(pickle_in) # Load features object
  21.  
  22. # %%
  23. # SHAP VALUE COMPUTATION
  24. explainer = shap.TreeExplainer(booster)
  25. shap_values = explainer.shap_values(features).astype('float64')
  26.  
  27. # %%
  28. # SHAP ATTRIBUTIONS
  29. shap.summary_plot(shap_values, features, max_display=20, show=False, auto_size_plot=True)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top