我是 python 编程的新手,想安装 SHAP。安装 SHAP 后,我收到了基本代码的错误,这些代码之前执行得很好(pandas 和 numpy)。我的版本是 python 3.7.1 conda 4.7.11 pd__version__ :'0.23.4'
我遇到了类似的问题并尝试进行故障排除,但现在 SHAP 和 numpy、pandas 都无法正常工作。我正在为 Windows 开发 anaconda 发行版。并pip install --upgrade
没有解决我的问题。
#Explaining with SHAP
import shap
ImportError Traceback (most recent call last)
<ipython-input-15-f08ae71e45dd> in <module>
1 #Explaining with SHAP
----> 2 import shap
~\AppData\Local\Continuum\anaconda3\lib\site-packages\shap\__init__.py in <module>
9 from .explainers.gradient import GradientExplainer
10 from .explainers.linear import LinearExplainer
---> 11 from .plots.summary import summary_plot
12 from .plots.dependence import dependence_plot
13 from .plots.force import force_plot, initjs, save_html
~\AppData\Local\Continuum\anaconda3\lib\site-packages\shap\plots\summary.py in <module>
13 pass
14 from . import labels
---> 15 from . import colors
16
17 # TODO: remove unused title argument / use title argument
~\AppData\Local\Continuum\anaconda3\lib\site-packages\shap\plots\colors.py in <module>
5
6 import numpy as np
----> 7 import skimage.color
8
9 try:
~\AppData\Local\Continuum\anaconda3\lib\site-packages\skimage\__init__.py in <module>
174 dtype_limits)
175
--> 176 from .util.lookfor import lookfor
177 from .data import data_dir
178
~\AppData\Local\Continuum\anaconda3\lib\site-packages\skimage\util\__init__.py in <module>
6 from .apply_parallel import apply_parallel
7
----> 8 from .arraycrop import crop
9 from ._regular_grid import regular_grid, regular_seeds
10 from .unique import unique_rows
~\AppData\Local\Continuum\anaconda3\lib\site-packages\skimage\util\arraycrop.py in <module>
6
7 import numpy as np
----> 8 from numpy.lib.arraypad import _validate_lengths
9
10
ImportError: cannot import name '_validate_lengths' from 'numpy.lib.arraypad' (C:\Users\z026355\AppData\Local\Continuum\anaconda3\lib\site-packages\numpy\lib\arraypad.py)
目前甚至 pd.read_csv 都不起作用
os.chdir(r"C:\Users\z026355\Desktop\Titanic")
with open("train.csv", encoding="utf8", errors='ignore') as g:
data = pd.read_csv(g)
Traceback (most recent call last):
File "<ipython-input-136-f58724e2278b>", line 2, in <module>
data = pd.read_csv(g)
File "C:\Users\z026355\AppData\Local\Continuum\anaconda3\lib\site-packages\pandas\io\parsers.py", line 678, in parser_f
error_bad_lines=error_bad_lines,
File "C:\Users\z026355\AppData\Local\Continuum\anaconda3\lib\site-packages\pandas\io\parsers.py", line 440, in _read
filepath_or_buffer, encoding, compression
File "C:\Users\z026355\AppData\Local\Continuum\anaconda3\lib\site-packages\pandas\io\parsers.py", line 774, in __init__
File "C:\Users\z026355\AppData\Local\Continuum\anaconda3\lib\site-packages\pandas\io\parsers.py", line 797, in _get_options_with_defaults
Passed dialect overrides any of the related parser options
AttributeError: module 'pandas.compat' has no attribute 'iteritems'
升级或重新安装 pandas 已满足要求。