| ShapleyMats | R Documentation |
This function computes the SHAP values of each rule and arranges them in a matrix that can be used to compute SHAP values of the model as a whole.
ShapleyMats(
data,
data_test = data,
Rs,
Rs_test = Rs,
id_mat,
interactions = FALSE
)
data |
a dataframe containing the data used to estimate the expectations in SHAP values |
data_test |
a dataframe containing the points to compute the SHAP values of. By default, this coincides with the datapoints used to estimate SHAP values. |
Rs |
a list of as many matrices as there are rules to compute the SHAP values for.
The |
Rs_test |
same as Rs, but computed for the (possibly different) observations provided
from the |
id_mat |
A matrix with as many rows as there are rules and as many columns as there
are predictors. The |
interactions |
A logical parameter determining whether interaction SHAP values should also be computed. |
Code written by and used with permission from Giorgio Spadaccini.
marginal A matrix with n\cdot p rows and as many columns as
there are terms (both linear and rules). It is obtained by vertically
stacking matrices of n rows. Each submatrix focuses on the SHAP values
of a different predictor: the (i,k)-th entry of the j-th of
such submatrices represents the contribution of the k-th term to
the SHAP value of the i-th datapoint for the j-th predictor.
The first p terms are the linear terms, and the remaining columns
refer to the rules.
interaction A matrix with n\cdot p^2 rows and as many columns as
there are terms (both linear and rules). It is obtained by vertically
stacking matrices of n \cdot p rows. Each submatrix is in turn split
into p subsubmatrices which focuses on the interaction SHAP values
of a different pair of predictors: the (i,k)-th entry of the j-th
subsubmatrix of the j'-th submatrix represents the contribution of the
k-th term to the SHAP value of the i-th datapoint for the
interaction between the j-th and the j'-th predictor.
The first p terms are the linear terms, and the remaining columns
refer to the rules.
Giorgio Spadaccini
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.