-
-
Save marnixkoops/8e8636cb17e55981a71b5cd38f7332ad to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # %% markdown | |
| # WEER IMPACT | |
| # %% | |
| # SETUP | |
| import pandas as pd | |
| import numpy as np | |
| import pickle | |
| import matplotlib | |
| import matplotlib.pyplot as plt | |
| import shap | |
| shap.initjs() | |
| # %% | |
| # DATA | |
| pickle_in = open('booster.pickle', 'rb') | |
| booster = pickle.load(pickle_in) # Load XGBoost booster object | |
| pickle_in = open('features.pickle', 'rb') | |
| features = pickle.load(pickle_in) # Load features object | |
| # %% | |
| # SHAP VALUE COMPUTATION | |
| explainer = shap.TreeExplainer(booster) | |
| shap_values = explainer.shap_values(features).astype('float64') | |
| # %% | |
| # SHAP ATTRIBUTIONS | |
| shap.summary_plot(shap_values, features, max_display=20, show=False, auto_size_plot=True) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment