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

Xgb bugfix #267

Merged
merged 2 commits into from
Nov 7, 2024
Merged

Xgb bugfix #267

merged 2 commits into from
Nov 7, 2024

Conversation

mmschlk
Copy link
Owner

@mmschlk mmschlk commented Nov 7, 2024

TLDR: This PR fixes #250, adds tests with xgb models and finds a bug/inconsitency in shap and xgboost.sklearn.XGBClassifier that is not present in shapiq.

Bugfix of #250.

The bug that the baseline prediction was not properly set stems from the fact that xgboost models (note models and not the individual boosters) contain an model.base_score and/or model.intercept_ attributes that store the empty prediction of the xgb models (as log-odds). Now this base_score/intercept is added to the values of the xgb model

Uncovers a bug in shap (not in shapiq)

The test_tree_explainer.test_xgboost_shap_error. contains a test uncovering some inconsistencies with shap: The test is used to show that the shapiq implementation is correct and the shap implementation is doing something weird. For some instances (e.g. the one used in this test) the SHAP values are different from the shapiq values. However, when we round the thresholds of the xgboost trees in shapiq, then the computed explanations match. This is a strange behavior as rounding the thresholds makes the model less true to the original model but only then the explanations match.

@mmschlk mmschlk requested review from hbaniecki and removed request for hbaniecki November 7, 2024 12:05
@mmschlk mmschlk merged commit bdf9ce9 into main Nov 7, 2024
8 checks passed
@mmschlk mmschlk deleted the xgb_bugfix branch November 7, 2024 12:07
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

Successfully merging this pull request may close these issues.

Baseline Prediction for TreeExplainer and XGBoost is not being computed correctly.
1 participant