Skip to content

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")

Calls to TreeExplainer that pass a non-"raw" model_output= together with feature_perturbation="tree_path_dependent" or without a background data argument.

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".

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.