Skip to content

shap/plot-raw-shap-values

Pack Severity Fix Versions
shap error none, edit by hand All versions

shap.plots.waterfall() and shap.plots.beeswarm() require a shap.Explanation object and raise TypeError when given the raw NumPy array returned by explainer.shap_values(X).

shap.plots.waterfall(explainer.shap_values(X_val)[0])
explanation = explainer(X_val)
shap.plots.waterfall(explanation[0])

Calls to waterfall(...), waterfall_plot(...), or beeswarm(...) that pass explainer.shap_values(...) (or a subscript of it) directly.

Call the explainer (explanation = explainer(X_val)) to obtain a shap.Explanation, then pass explanation to shap.plots.beeswarm or explanation[i] to shap.plots.waterfall.

shap.plots.waterfall() and shap.plots.beeswarm() require a shap.Explanation object and raise TypeError when passed a raw array from explainer.shap_values(). Call explainer(X) to obtain an Explanation object (and slice explanation[i] for waterfall).

See all rules in the shap pack.