shap
shap copied to clipboard
Documentation of maskers
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!
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
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).