shap.maskers.Independent

class shap.maskers.Independent(data, max_samples=100)

This masks out tabular features by integrating over the given background dataset.

__init__(data, max_samples=100)

Build a Independent masker with the given background data.

Parameters
datanumpy.ndarray, pandas.DataFrame

The background dataset that is used for masking.

max_samplesint

The maximum number of samples to use from the passed background data. If data has more than max_samples then shap.utils.sample is used to subsample the dataset. The number of samples coming out of the masker (to be integrated over) matches the number of samples in the background dataset. This means larger background dataset cause longer runtimes. Normally about 1, 10, 100, or 1000 background samples are reasonable choices.

Methods

__init__(data[, max_samples])

Build a Independent masker with the given background data.

invariants(x)

This returns a mask of which features change when we mask them.

load(in_file[, instantiate])

Load a Tabular masker from a file stream.

save(out_file)

Write a Tabular masker to a file stream.

invariants(x)

This returns a mask of which features change when we mask them.

This optional masking method allows explainers to avoid re-evaluating the model when the features that would have been masked are all invariant.

classmethod load(in_file, instantiate=True)

Load a Tabular masker from a file stream.

save(out_file)

Write a Tabular masker to a file stream.