Closed dfsnow closed 2 years ago
Hi @dfsnow, thanks for the note. Setting adjust = TRUE
has no affect on the output when using exact = TRUE
since they are already supposed to be additive. I'm not sure why the SHAP values aren't additive here (and I get the same issue when using XGBoost directly), so it may be better to ask on the XGBoost issues page. The bias column/term should be the average of all the training predictions (i.e., E(f(x))), which also corresponds to the difference between a particular prediction and the sum of its corresponding Shapley values.
Interesting. For what it's worth, this issue is also true of LightGBM. I'll make a quick issue on the xgboost repo. Thanks!
Hi! Thanks for the great package. I want to clarify a point of confusion I have before proceeding. I found the sample code you posted here and ran it locally. Quick reprex:
In this code, the SHAP values' sum is not equal to the difference between pred and mean(pred) as suggested. Instead the SHAP values' sum is (nearly) equal to the
BIAS
term from thestats::predict(object, X, predcontrib = TRUE, ...)
call inexplain.xgb.Booster
whenexact = TRUE
.So, quick questions:
adjust = TRUE
have the same effect forexact = TRUE
output as it does forexact = FALSE
output? In the line above (explain(mod, X = dataX, exact = TRUE, adjust = TRUE)
),adjust = TRUE
has no function. Is is simply passed on to the predict method of xgb.Booster and silently swallowed. Is this the intended behavior?predict(xgb.Booster, newdata = X, predcontrib = FALSE)
as the last matrix column) andmean(prediction)
? I scoured the xgboost/lightgbm docs but couldn't find much.