pyreal
pyreal copied to clipboard
Resolve error from `ShapExplainer(self.model.predict, dataset)`
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:
- Require all models to support
__call__()in addition topredict()andfit(), so we can always callShapExplainer(self.model, dataset). - Look into the Shap library more to find out how to get the
shap_valueswith other explainer objects(e.g.Exact) returned byShapExplainer.