-
Notifications
You must be signed in to change notification settings - Fork 33
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
The prediction of XGBoostClassifier doesn't match the output of ShapIQ #353
Comments
I don't see an image/waterfall plot. So I can only speculate. But yes, you are right, the SV do not match with what comes out of XGBoost when you run # explain with shapiq
explainer_shapiq = TreeExplainer(
model=xgb_clf_model, max_order=1, index="SV", class_index=class_label
)
sv = explainer_shapiq.explain(x=x_explain_shapiq)
sum_of_sv = sv
# get the margin prediction of the model
prediction = xgb_clf_model.predict(x_explain.reshape(1, -1), output_margin=True)
prediction = prediction[0, class_label]
print(prediction == sum_of_sv)
True There is a paper discussing that the Margins are not a very nice object to explain models with. But up to now neither Does this answer your question? |
Thank you for the prompt response! However, I'm still not getting the same output from shapiq and XGBClassifier. Here is the code that I used
where
|
When I use the
At the first glance, the SHAP values output by |
Ah okay, just to make sure: First, are you certain you are explaining the correct class in the explainer_shapiq = shapiq.TreeExplainer(
model=model, max_order=1, index="SV", class_index=class_index
) Second, what happens if you do not run: sum_of_sv = sv.get_n_order_values(1).sum()
base_value = sv.baseline_value but sum_of_sv = sum(sv.values) since with shapiq v1.2.3, we made sure that min_order is set to 0 for TreeExplainer which should include the baseline value inside the Third is it possible to create a minimal reproducible case where shap returns the prediction and shapiq does not? Because here it is the same. Best |
Hi Max, I'm running the same example you have but for binary case
And here is the output that I got
|
Ah okay, I will take a look at this more closely! However, the Shapley values are the same for Could you let me know what's your |
It's |
The log odd of f(x) in the waterfall plot does not match the prediction I got from XGBoostClassifier model predict_proba method.
Also, should the baseline value be close to the log odd of the average of y? The log odd of E[f(X)] I got from the waterfall plot does not match the average of ground truth. Please correct me if I'm wrong.
The text was updated successfully, but these errors were encountered: