Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No module named 'shap.explainers' with 0.13 in LightGBM notebook #54

Closed
stefan-jansen opened this issue Apr 9, 2018 · 12 comments
Closed

Comments

@stefan-jansen
Copy link

stefan-jansen commented Apr 9, 2018

After installing 0.13 (with lightgbm 2.1.0), the import for the notebook 'Census income classification with LightGBM' fail as follows (works fine with 0.12.1):

ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-1-5f776e0a17f7> in <module>()
      1 from sklearn.model_selection import train_test_split
      2 import lightgbm as lgb
----> 3 import shap
      4 
      5 # print the JS visualization code to the notebook

~/.virtualenvs/shap/lib/python3.6/site-packages/shap-0.13-py3.6.egg/shap/__init__.py in <module>()
      5 from iml.links import Link, IdentityLink, LogitLink
      6 from iml.common import Instance, Model
----> 7 from .explainers.kernel import KernelExplainer, kmeans
      8 from .explainers.tree import TreeExplainer
      9 from .plots import visualize, plot, summary_plot, joint_plot, interaction_plot, dependence_plot, force_plot

ModuleNotFoundError: No module named 'shap.explainers'
pip list

backcall (0.1.0)
bleach (2.1.3)
cycler (0.10.0)
decorator (4.2.1)
entrypoints (0.2.3)
html5lib (1.0.1)
iml (0.5.1)
ipykernel (4.8.2)
ipython (6.3.1)
ipython-genutils (0.2.0)
ipywidgets (7.2.0)
jedi (0.11.1)
Jinja2 (2.10)
jsonschema (2.6.0)
jupyter (1.0.0)
jupyter-client (5.2.3)
jupyter-console (5.2.0)
jupyter-core (4.4.0)
kiwisolver (1.0.1)
lightgbm (2.1.0)
llvmlite (0.22.0)
MarkupSafe (1.0)
matplotlib (2.2.2)
mistune (0.8.3)
nbconvert (5.3.1)
nbformat (4.4.0)
notebook (5.4.1)
numba (0.37.0)
numpy (1.14.2)
pandas (0.22.0)
pandocfilters (1.4.2)
parso (0.1.1)
pexpect (4.4.0)
pickleshare (0.7.4)
pip (9.0.3)
prompt-toolkit (1.0.15)
ptyprocess (0.5.2)
Pygments (2.2.0)
pyparsing (2.2.0)
python-dateutil (2.7.2)
pytz (2018.3)
pyzmq (17.0.0)
qtconsole (4.3.1)
scikit-learn (0.19.1)
scipy (1.0.1)
Send2Trash (1.5.0)
setuptools (39.0.1)
shap (0.13)
simplegeneric (0.8.1)
six (1.11.0)
terminado (0.8.1)
testpath (0.3.1)
tornado (5.0.2)
tqdm (4.21.0)
traitlets (4.3.2)
wcwidth (0.1.7)
webencodings (0.5.1)
widgetsnbextension (3.2.0)
@stefan-jansen stefan-jansen changed the title No module named 'shap.explainers' No module named 'shap.explainers' with 0.13 in LightGBM notebook Apr 9, 2018
@slundberg
Copy link
Collaborator

Working on this now. I am undoing the numba dependency I added today, which will allow travis to check this again.

@slundberg
Copy link
Collaborator

Travis is happy now with 13.1, and it works on my checkout. Let me know if that fixed it. (seems like numba and pip don't play nice)

@firmai
Copy link

firmai commented Apr 10, 2018

Hi, I just installed - Successfully installed iml-0.5.1 shap-0.13.1

One hour ago - fresh package, I too get this error:

ModuleNotFoundError: No module named 'shap.explainers'

@slundberg
Copy link
Collaborator

@firmai what OS are you on?

@slundberg
Copy link
Collaborator

I just pushed a fix to the setup.py script that should fix it (0.13.2). I'll also test more here though

@slundberg
Copy link
Collaborator

Everything seems to be working again now. This was all started by pushing a new core for the Tree SHAP method to support sklearn models. So now it looks like that core alg, from what I can tell, is working.

If anyone still has issues let me know and I'll reopen this.

@Benno26
Copy link

Benno26 commented Apr 11, 2018

Thanks @slundberg, I had this issue yesterday however it is fixed now after the update.

@e7dud7e
Copy link

e7dud7e commented Oct 27, 2018

Hi! I tried to install shap using pip install shap; it appears to install properly inside my environment. I' using Python 3.6.4 on a Mac OS. Would you please have any suggestions? Thank you!

@slundberg
Copy link
Collaborator

@e7dud7e is anything wrong?

@e7dud7e
Copy link

e7dud7e commented Nov 3, 2018

Hi! Thanks for checking back! Pip install works fine on a virtual machine that I’m running, so I think I’ll be okay. It just didn’t work on my local machine, but will just stick with the virtual machine. Thanks!

connortann pushed a commit to prabathbr/shap that referenced this issue Jun 2, 2023
* chore: remove F821 from ruff ignore

* fix: missing mpl import

* fix: undefined name errors in beeswarm

And also temporarily remove the SHAP interaction beeswarm plot code
(it's not runnable at the moment, because we ensured that the ndim of
SHAP values was 2 above, so it can never be 3 to trigger the interaction
beeswarm plot here).

The removal of code here is mostly just to appease ruff.
Will create a separate issue for this to re-introduce SHAP interaction
values plotting again later on. Maybe it should be implemented as a
separate function.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants