Sample covariate values, predict and calculate Shapley values. The sampling and prediction can be done in batches
if n_batches
is greater than 1.
prepare_and_predict(explainer, n_batches, prediction_zero, ...)
An explainer
object to use for explaining the observations.
See shapr
.
Positive integer. Specifies how many batches the total number of feature combinations should be split into when calculating the contribution function for each test observation. The default value is 1. Increasing the number of batches may significantly reduce the RAM allocation for models with many features. This typically comes with a small increase in computation time.
Numeric. The prediction value for unseen data, typically equal to the mean of the response.
Arguments passed to prepare_data
with exception of only_return_contrib_dt
,
which is only passed to explain. If TRUE
the
data.table
from prediction
is returned, else an object of class shapr
.
Each column (except for row_id
) correspond to the vector v_D
in Equation 7 in the reference.
The Shapley values can be calculated by t(explainer$W %*% dt_contrib[, -"row_id"]))
A list. See explain
for more information.