我正在尝试安装shap软件包,并不断出现以下错误
ModuleNotFoundError: No module named 'shap'
我已经在笔记本以及终端中输入了以下内容
!conda install -c conda-forge shap
!conda install shap --yes
这是错误的行
!pip install shap
import shap
explainer = shap.TreeExplainer(model)
shap_values = explainer.shap_values(X)
我目前在Mac上
答案 0 :(得分:2)
我在使用 pip install shap 命令时遇到了同样的问题。但是, conda install 有效。我使用 Mac。
conda install -c conda-forge shap
答案 1 :(得分:0)
它应该与
一起使用pip install shapely
如果没有,请尝试
conda install shapely
答案 2 :(得分:0)
这与类似问题有关。它可能会对您有所帮助。
Modules are installed using pip on OSX but not found when importing
如果上述方法无效,请尝试以下操作:
卸载并重新安装SHAP
将Numpy更新为最新版本,然后:
pip install git+https://github.com/slundberg/shap.git
如果上述方法不起作用,则可能是这样:
要匀称安装(https://pypi.org/project/Shapely/)吗?在python中,您可以通过以下方式进行整形安装
pip install shapely
对于Windows,可以通过从http://www.lfd.uci.edu/~gohlke/pythonlibs/#shapely下载.whl来安装shapley,然后执行
pip install <name of whl file>
或者如果您正在使用anaconda,则可以使用conda-forge来整形
conda config --add channels conda-forge
conda install shapely