The interface of kernelshap()
has been revised. Instead
of specifying a prediction function, it suffices now to pass the fitted
model object. The default pred_fun
is now
stats::predict
, which works in most cases. Some other cases
are catched via model class (“ranger” and mlr3 “Learner”). The
pred_fun
can be overwritten by a function of the form
function(object, X, ...)
. Additional arguments to the
prediction function are passed via ...
of
kernelshap()
.
Some examples:
kernelshap(fit, X, bg_X)
kernelshap(fit, X, bg_X, type = "response")
kernelshap(fit, X, bg_X, pred_fun = function(m, X) exp(predict(m, X)))
kernelshap()
has received a more intuitive interface,
see breaking change above.kernelshap()
, e.g., using the “doFuture” package, and then
set parallel = TRUE
. Especially on Windows, sometimes not
all global variables or packages are loaded in the parallel instances.
These can be specified by parallel_args
, a list of
arguments passed to foreach()
.kernelshap()
has
become much faster.matrix
, data.frame
s, and
tibble
s, the package now also accepts
data.table
s (if the prediction function can deal with
them).kernelshap()
is less picky regarding the output
structure of pred_fun()
.kernelshap()
is less picky about the column structure
of the background data bg_X
. It should simply contain the
columns of X
(but can have more or in different order). The
old behaviour was to launch an error if
colnames(X) != colnames(bg_X)
.m = "auto"
has been changed from
trunc(20 * sqrt(p))
to
max(trunc(20 * sqrt(p)), 5 * p
. This will have an effect
for cases where the number of features \(p
> 16\). The change will imply more robust results for large
p.ks_extract(, what = "S")
.MASS::ginv()
, the Moore-Penrose pseudoinverse using
svd()
.This is the initial release.