shap/tree-explainer-path-dependent-model-output
| Pack | Severity | Fix | Versions |
|---|---|---|---|
| shap | error | none, edit by hand | All versions |
shap.TreeExplainer only supports model_output="raw" under feature_perturbation="tree_path_dependent" (including when feature_perturbation="auto" runs without a background dataset). Passing "probability", "log_loss", or a method name without a background dataset raises ValueError.
explainer = shap.TreeExplainer(model, model_output="probability")explainer = shap.TreeExplainer(model, X_bg, feature_perturbation="interventional", model_output="probability")What the rule reports
Section titled “What the rule reports”Calls to TreeExplainer that pass a non-"raw" model_output= together with feature_perturbation="tree_path_dependent" or without a background data argument.
How to fix it
Section titled “How to fix it”Supply a training background dataset (such as shap.sample(X_train, 100)) with feature_perturbation="interventional", or explain the raw tree margin with model_output="raw".
Diagnostic message
Section titled “Diagnostic message”TreeExplainer only supports model_output='raw' with feature_perturbation='tree_path_dependent' (or when no background data is provided) and raises ValueError otherwise. Pass a background dataset with feature_perturbation='interventional' or use model_output='raw'.See all rules in the shap pack.