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])What the rule reports
Section titled “What the rule reports”Calls to waterfall(...), waterfall_plot(...), or beeswarm(...) that pass explainer.shap_values(...) (or a subscript of it) directly.
How to fix it
Section titled “How to fix it”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.
Diagnostic message
Section titled “Diagnostic message”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.