Skip to content

shap

The shap pack checks TreeSHAP, linear, and kernel explainers, background leakage, and Explanation plotting APIs against SHAP 0.54 on files that import shap.

Rules Safe fix Unsafe fix Manual fix
10 0 0 10
Rule Severity Fix What it finds
tree-explainer-path-dependent-model-output error none shap.TreeExplainer only supports model_output="raw" under feature_perturbation="tree_path_dependent" (including when feature_perturbation="auto" runs without a background dataset).
tree-explainer-interventional-without-data warning none shap.TreeExplainer(model, feature_perturbation="interventional") without a background dataset emits a FutureWarning and silently falls back to "tree_path_dependent".
tree-explainer-deprecated-approximate warning none Passing approximate= to shap.TreeExplainer(...) has been deprecated since SHAP 0.47.
linear-explainer-removed-feature-dependence error none feature_dependence= was removed from shap.LinearExplainer and raises ValueError.
linear-explainer-deprecated-perturbation warning none feature_perturbation= on shap.LinearExplainer is deprecated and emits a FutureWarning in favor of passing an explicit masker (shap.maskers.Independent, shap.maskers.Impute, or shap.maskers.Partition).
kernel-explainer-l1-reg-auto warning none l1_reg="auto" in KernelExplainer.shap_values() emits a DeprecationWarning in SHAP 0.54.
explainer-background-from-test warning none Using holdout or test rows as the background dataset for shap.TreeExplainer, shap.Explainer, shap.KernelExplainer, shap.LinearExplainer, or shap.PermutationExplainer sets the SHAP baseline (expected_value) and interventional reference distribution from held-out data.
Rule Severity Fix What it finds
beeswarm-ax-with-plot-size error none shap.plots.beeswarm(..., ax=ax) raises ValueError unless plot_size=None is also passed, because plot_size defaults to "auto" and SHAP refuses to resize an externally supplied axes.
plot-raw-shap-values error none 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).
legacy-bar-plot warning none shap.bar_plot() is a deprecated alias for bar_legacy() and emits a DeprecationWarning in SHAP 0.54.