Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Additivity check fails with XGBoost #31

Open
ThomasBury opened this issue Jul 24, 2023 · 0 comments
Open

Additivity check fails with XGBoost #31

ThomasBury opened this issue Jul 24, 2023 · 0 comments

Comments

@ThomasBury
Copy link

ThomasBury commented Jul 24, 2023

Hi,

when using XGB, the additivity check fails, while it does not when using native shap or lightgbm
Using xgboost 1.7.6, shap 0.41.0 and fasttreeshap 0.1.6

could it be linked to #15 ?

example (changing algorithm or feature_perturbation lead to the same error):

from sklearn.datasets import make_regression
from xgboost import XGBRegressor
from lightgbm import LGBMRegressor
from fasttreeshap import TreeExplainer as FastTreeExplainer

X, y = make_regression(n_samples=1000, n_features=10, n_informative=8, noise=1, random_state=8)
model = XGBRegressor()  #LGBMRegressor()
model.fit(X, y)
explainer = FastTreeExplainer(model, algorithm="auto", shortcut=False, feature_perturbation="tree_path_dependent")
shap_matrix = explainer.shap_values(X)
Exception: Additivity check failed in TreeExplainer! Please ensure [...]

The following runs fine

explainer = shap.TreeExplainer(model, feature_perturbation="tree_path_dependent")
shap_values = explainer.shap_values(X)

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant