Shap: module 'shap' has no attribute 'utils'

Created on 4 Aug 2020  路  2Comments  路  Source: slundberg/shap

I'm using the following notebook below in an attempt to recreate the bar graph with feature clustering.

When I execute clustering = shap.utils.hclust(X, y), I receive the following error:

module 'shap' has no attribute 'utils'

https://github.com/slundberg/shap/blob/master/notebooks/plots/bar.ipynb

Most helpful comment

I had the same problem. Here's how I fixed it

  1. uninstall shap pip uninstall shap==0.35
  2. clone most recent shap from github -git clone https://github.com/slundberg/shap.git
  3. install from source, as of today, shap==0.36 python setup.py install
  4. copy all files and directories in source shap to your env or destination cp -r ./ /[destination_directory]
  5. restart jupyter kernel and import shap. should work

All 2 comments

I had the same problem. Here's how I fixed it

  1. uninstall shap pip uninstall shap==0.35
  2. clone most recent shap from github -git clone https://github.com/slundberg/shap.git
  3. install from source, as of today, shap==0.36 python setup.py install
  4. copy all files and directories in source shap to your env or destination cp -r ./ /[destination_directory]
  5. restart jupyter kernel and import shap. should work

Same issue here. Followed @kamalsky recommendations but python setup.py install gives error: package init file 'shap/__init__.py' not found (or not a regular file) & error: package directory 'shap/explainers' does not exist.

Was this page helpful?
0 / 5 - 0 ratings