Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Import a package doesn't return error, but doesn't work

I installed SHAP package using pip. when I’m using pip freeze I get:

...

    shap==0.40.0

...

I’m importing the package with import shap

when I check what does return shap I get:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

enter image description here

If call for SHAP attribute like: shap_explainer = shap.TreeExplainer(clf) ,I get the error: AttributeError: module 'shap' has no attribute 'TreeExplainer'

>Solution :

Your python script file is called shap.py. What you are doing is actually importing your own script and not the shap module. Python first looks in the script directory for imports, and since it finds it, it stops searching and thus never finds the shap module you would need. Rename your script to something different and it should work.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading