bgreenwell/fastshap

baseline is 0

mayer79 opened this issue · 3 comments

@bgreenwell : one question about the baseline fnull:

When I run this code from the master branch, the baseline is 0. Same for ranger models.

library(fastshap)

fit <- lm(Sepal.Length ~ Sepal.Width + Petal.Length, data = iris)

shap <- fastshap::explain(
  fit, 
  X = iris[c("Sepal.Width", "Petal.Length")],
  nsim = 100, 
  pred_wrapper = predict,
  shap_only = FALSE  # Same with shap_only = TRUE
)

What am I doing wrong? :-)

Oh, simply setting adjust = TRUE seems to fix it!

Yep, that was the intention. The baseline is not calculated unless it's needed for the adjustment; and will default to zero in that case. There's also a baseline argument to use if you don't want explain() to compute it from X.

Got it, thx.