linkedin / linkedin/FastTreeSHAP

Additivity check fails with XGBoost

Open
#31 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
566
Forks
38
PR merge metrics
No merged PRs in 30d

Description

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 https://github.com/linkedin/FastTreeSHAP/issues/15 ?

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

```python
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

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running the reported XGBRegressor example with xgboost 1.7.6, shap 0.41.0, and fasttreeshap 0.1.6, then compare it with the native SHAP and LightGBM cases. Inspect fasttreeshap.TreeExplainer's additivity-check path and its XGBoost handling, including the linked issue, to identify why the check fails. Done means the XGBoost example completes without the additivity exception while the check remains valid.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
machine-learning
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.