shap icon indicating copy to clipboard operation
shap copied to clipboard

AttributeError: module 'shap' has no attribute 'DeepExplainer'

Open MayurDivate opened this issue 6 years ago • 8 comments

Hi,

If I run the code using python script, get the following error. However, I don't get any error if I use Jupyter notebook. The same code works fine.

Traceback (most recent call last):
  File "shap.py", line 1, in <module>
    import shap
  File "/home/ubuntu/Project/1_DNN/shap.py", line 67, in <module>
    explainer_shap = shap.DeepExplainer(model=model, data=testX)
AttributeError: module 'shap' has no attribute 'DeepExplainer'

shap version = 0.35.0 installed using pip3

How can I make my python script to work, so that I can run it on big data?

Thanks, Mayur

MayurDivate avatar Apr 16 '20 07:04 MayurDivate

Did the installation succeed? You could try uninstalling and reinstalling using pip install shap but I don't think this would make a difference...

alexcoca avatar Apr 16 '20 09:04 alexcoca

Yes, it is successful.

Below is the screenshot.

Screen Shot 2020-04-16 at 7 15 32 PM

MayurDivate avatar Apr 16 '20 09:04 MayurDivate

So have you tried uninstalling and installing again? Failing that you can always check if it works by cloning the github repo. It works for me.

alexcoca avatar Apr 16 '20 09:04 alexcoca

Yeah, I have tried many times. Sure I will try cloning also.

Thanks, Mayur

MayurDivate avatar Apr 16 '20 09:04 MayurDivate

background = images[:100] e = shap.DeepExplainer(model, background)

I am getting the same error for the above code - AttributeError: module 'shap' has no attribute 'DeepExplainer'. Is it resolved?

KahiniWadhawan avatar Feb 12 '21 09:02 KahiniWadhawan

@KahiniWadhawan which Python version you use and which SHAP?

kabartay avatar Feb 12 '21 10:02 kabartay

which shap version having these functionalities

ayushrathore111 avatar Aug 12 '23 19:08 ayushrathore111

I think all of them, maybe you are importing shap wrong?

JoJoBarthold2 avatar May 18 '24 09:05 JoJoBarthold2