pyreal icon indicating copy to clipboard operation
pyreal copied to clipboard

Resolve error from `ShapExplainer(self.model.predict, dataset)`

Open wei-enwang opened this issue 3 years ago • 0 comments

ShapExplainer() automatically selects an explanation algorithm based on the arguments. If we call the explainer with ShapExplainer(self.model.predict, dataset) instead of ShapExplainer(self.model, dataset), sometimes the following error occurs because the explainer selected by ShapExplainer(self.model.predict, dataset) does not support explainer.shap_values(x) :

E           AttributeError: 'Exact' object has no attribute 'shap_values'

We can potentially solve this in two ways:

  1. Require all models to support __call__() in addition to predict() and fit(), so we can always call ShapExplainer(self.model, dataset).
  2. Look into the Shap library more to find out how to get the shap_values with other explainer objects(e.g. Exact) returned by ShapExplainer.

wei-enwang avatar Apr 12 '22 16:04 wei-enwang