sklearn ImportError:无法导入名称stable_cumsum

时间:2016-11-09 14:20:37

标签: python scikit-learn anaconda

我想从sklearn导入StratifiedKFold进行交叉验证。我的电脑使用scikit-learn 0.18。 在python控制台中,我输入:

 from sklearn.model_selection import StratifiedKFold

弹出以下错误消息:

  File "<ipython-input-307-7880cb661350>", line 1, in <module>
    from sklearn.model_selection import StratifiedKFold

  File "C:\Users\user\Anaconda2\lib\site-packages\sklearn\model_selection\__init__.py", line 1, in <module>
    from ._split import BaseCrossValidator

  File "C:\Users\user\Anaconda2\lib\site-packages\sklearn\model_selection\_split.py", line 35, in <module>
    from ..gaussian_process.kernels import Kernel as GPKernel

  File "C:\Users\user\Anaconda2\lib\site-packages\sklearn\gaussian_process\__init__.py", line 13, in <module>
    from .gpr import GaussianProcessRegressor

  File "C:\Users\user\Anaconda2\lib\site-packages\sklearn\gaussian_process\gpr.py", line 15, in <module>
    from sklearn.gaussian_process.kernels import RBF, ConstantKernel as C

  File "C:\Users\user\Anaconda2\lib\site-packages\sklearn\gaussian_process\kernels.py", line 30, in <module>
    from ..metrics.pairwise import pairwise_kernels

  File "C:\Users\user\Anaconda2\lib\site-packages\sklearn\metrics\__init__.py", line 7, in <module>
    from .ranking import auc

  File "C:\Users\user\Anaconda2\lib\site-packages\sklearn\metrics\ranking.py", line 30, in <module>
    from ..utils.extmath import stable_cumsum

ImportError: cannot import name stable_cumsum

1 个答案:

答案 0 :(得分:0)

问题已经解决:

删除scikit-learn:

conda remove scikit-learn

然后重新安装:

pip install -U scikit-learn