shap icon indicating copy to clipboard operation
shap copied to clipboard

Documentation of maskers

Open JoElfner opened this issue 5 years ago • 1 comments
trafficstars

This is rather a question than an issue. But I thought this might be the best place to ask, since there is no doc on maskers (yet) and I can't find any information on what would be best practice to use maskers in my case.

Let's assume I've got a sklearn-model which I evaluate using shap exact explainer.

This model is trained with a dataframe like this:

X_train = pd.DataFrame(
    data={
        'x1': np.arange(10) / 2.,
        'x2': np.arange(10)**2,
        'x3': [0, 1, 2, 0, 1, 2, 0, 0, 1, 2],
        'x4': [0, 1, 1, 0, 2, 2, 0, 0, 0, 0],
    }
)

The important variables here are x3 and x4. Both are categoric variables, which are transformed using a One-Hot-Encoder within the pipeline of sklearn-model. When x3 in (1, 2), then x4 can be element of [0, 1, 2], BUT for x3 == 0, only x4 == 0 is valid. Is there any way to use maskers to mask out this "forbidden" combination? I guess tabular masker would be correct, but I didn't manage to use it in this case.

Thanks in advance!

JoElfner avatar Sep 25 '20 14:09 JoElfner

Did you find an answer @JoElfner ?

There is now a bit of documentation around maskers on ReadTheDocs. For example https://shap.readthedocs.io/en/latest/example_notebooks/api_examples/maskers/custom.html

jonnor avatar Aug 09 '22 09:08 jonnor

Still an interesting issue, if it's possible a small reference would be nice (nicer than implementing it from scratch - invariants are difficult to utilize for it).

maayanorner avatar Jan 02 '23 18:01 maayanorner