Skip to main content
Looking for usage documentation? Check out Interpretability.

explain.permutation_shap

View source
Estimate SHAP values by antithetic permutation sampling. This is the algorithm of shap.PermutationExplainer with an independent masker: a hidden feature takes its values from each background row, and the prediction is averaged over the background rows. shap calls the model once per explained row, so a remote model pays the request overhead for every row. This function predicts the masked rows of many explained rows in each call of predict_fn. Each set of shown features is predicted once per explained row, and the all-hidden set once in total. So the number of masked rows is at most n_background * (1 + len(X) * (1 + 2 * n_permutations * (n_features - 1))), and fewer when orderings share sets, which is common with few features.
Parameters
Returns
Raises ValueError If an argument is invalid, or predict_fn returns the wrong number of predictions.

explain.ShapExplanation

View source
SHAP values for a set of explained rows. Attributes

ShapExplanation.to_shap

View source
Convert to a shap.Explanation, for use with the plots of shap.
Returns
Raises ImportError If shap is not installed.