Skip to content

shap/tree-explainer-interventional-without-data

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

shap.TreeExplainer(model, feature_perturbation="interventional") without a background dataset emits a FutureWarning and silently falls back to "tree_path_dependent".

explainer = shap.TreeExplainer(model, feature_perturbation="interventional")
explainer = shap.TreeExplainer(model, shap.sample(X_train, 100), feature_perturbation="interventional")

Calls to TreeExplainer requesting feature_perturbation="interventional" with data=None or no data argument.

Pass a background sample from the training data (typically 100 to 1000 rows), or switch to feature_perturbation="tree_path_dependent".

TreeExplainer with feature_perturbation='interventional' requires a background dataset and emits a FutureWarning while falling back to tree_path_dependent when data is omitted or None. Pass a background dataset such as shap.sample(X_train, 100) or use feature_perturbation='tree_path_dependent'.

See all rules in the shap pack.