# Using a custom masker

Here we show how to provide a custom Masker to any of the SHAP model agnostic explanation methods. Masking can often be domain dependent and so it often helpful to consider alternative ways to perturb your data beyond the default ones included with SHAP.

[1]:

import xgboost
import shap
import numpy as np

# train XGBoost model
model = xgboost.XGBClassifier().fit(X.values, y)

# A masking function takes a binary mask vector as the first argument and
# the model arguments for a single sample after that
# It returns a masked version of the input x, where you can return multiple
# rows to average over a distribution of masking types