Sample covariate values, predict and calculate Shapley values. The sampling and prediction can be done in batches
n_batches is greater than 1.
prepare_and_predict(explainer, n_batches, prediction_zero, ...)
explainer object to use for explaining the observations.
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
which is only passed to explain. If
prediction is returned, else an object of class
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.