Shap Summary Plots

Python

Here we use the Shap library to evaluate the features in our model. The first summery plot outputs a simple bar chart with features listed in order of importance. The 2nd plot again shows the features listed in order of importance but also how much, both positively and negatively the feature impacts the model.

 1|  import shap
 2|  shap.initjs()
 3|  
 4|  shap_values = shap.TreeExplainer(model).shap_values(X_train)
 5|  
 6|  shap.summary_plot(shap_values, X_train, plot_type="bar")
 7|  shap.summary_plot(shap_values, X_train)
Shap Summary Plots
Did you find this snippet useful?

Sign up for free to to add this to your code library