dsgibbons / shap

A game theoretic approach to explain the output of any machine learning model.
https://shap-community.readthedocs.io/en/latest/
MIT License
25 stars 5 forks source link

Re-implement `MimicExplainer` #57

Open thatlittleboy opened 1 year ago

thatlittleboy commented 1 year ago

Please see issue #33 for the background.

The original code for MimicExplainer was removed in PR #53 due to it being un-runnable.

EMorf commented 1 year ago

I had a look, and was able to piece back most of the code based on the locality of it, in particular https://github.com/slundberg/shap/blob/master/shap/explainers/_kernel.py was illuminating.

I have pushed the changes here but I have no idea as how to test; the comments are rather vague.

Also this seems to be related to this repo.

slundberg seems to be the main contributor there as well.

thatlittleboy commented 1 year ago

@EMorf Thanks for looking into this! Do you want to open a PR with the changes, so we can review the diffs more thoroughly?

but I have no idea as how to test

I'ld be happy with coverage for the .shap_values() and .shap_interaction_values() (but I see this is not implemented previously, we can raise a NotImplementedErrror for now and add a test for that) methods.

And looking at the tests within tests/explainers/, we should check for the additivity (base_val + sum(shap_values) ~= model_output) at the minimum.

EMorf commented 1 year ago

PR raised https://github.com/dsgibbons/shap/pull/92

Note that there are no ruff warnings now, but the code has not been tested. I will look into testing later, but any contributions are welcome.