pandasshapwaterfall

Missing features from SHAP waterfall plot in Anaconda


I have trained a LightGBM model called model and plotted the SHAP waterfall graph as follows:

explainer = TreeExplainer(model)
sv = explainer(X)


exp = Explanation(sv.values[:,:,0], 
                  sv.base_values[:,1], 
                  data=X.values, 
                  feature_names=X.columns)
idx = 0
waterfall(exp[idx])

The resulting graph looks like this:

enter image description here

The graph is truncated: at the bottom of the plot you can see that it reads: "8 other features". Is it possible to display the whole set of features in the waterfall plot?


Solution

  • You're looking for max_display param like:

    waterfall(exp[idx], max_display=20)