feedzai / timeshap

TimeSHAP explains Recurrent Neural Network predictions.
Other
162 stars 30 forks source link

Lack support for shap > 0.42.1 #56

Open daniegr opened 8 months ago

daniegr commented 8 months ago

Due to renaming of explainers in shap 0.43.0, TimeSHAP logic fails when the default pip install is used:

---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
Cell In[24], line 1
----> 1 from timeshap.explainer import local_report
      3 pruning_dict = {'tol': 0.025}
      4 event_dict = {'rs': 42, 'nsamples': 32000}

File ~\anaconda3\envs\env\lib\site-packages\timeshap\explainer\__init__.py:15
      1 #  Copyright 2022 Feedzai
      2 #
      3 #  Licensed under the Apache License, Version 2.0 (the "License");
   (...)
     12 #  See the License for the specific language governing permissions and
     13 #  limitations under the License.
---> 15 from .kernel import *
     16 from .pruning import *
     17 from .event_level import *

File ~\anaconda3\envs\env\lib\site-packages\timeshap\explainer\kernel\__init__.py:15
      1 #  Copyright 2022 Feedzai
      2 #
      3 #  Licensed under the Apache License, Version 2.0 (the "License");
   (...)
     12 #  See the License for the specific language governing permissions and
     13 #  limitations under the License.
---> 15 from .timeshap_kernel import TimeShapKernel

File ~\anaconda3\envs\env\lib\site-packages\timeshap\explainer\kernel\timeshap_kernel.py:53
     51 from shap.utils._legacy import convert_to_link, IdentityLink
     52 from shap.utils._legacy import convert_to_instance, convert_to_model
---> 53 from shap.explainers._kernel import Kernel
     54 from scipy.special import binom
     55 from scipy.sparse import issparse

ImportError: cannot import name 'Kernel' from 'shap.explainers._kernel' (C:\Users\user\anaconda3\envs\env\lib\site-packages\shap\explainers\_kernel.py)
AndreFCruz commented 2 months ago

The Kernel rename seems to have been introduced in shap/shap#3247 and should indeed fixed by pinning the requirement to shap<=0.42.1.

Thanks for the bug report!