在导入sklearn部分模块时,出现DeprecationWarning(弃用警告),形式如下:

C:\Adaconda2\lib\site-packages\sklearn\cross_validation.py:44: DeprecationWarning: This module was deprecated in version 0.18 in favor of the model_selection module into which all the refactored classes and functions are moved. Also note that the interface of the new CV iterators are different from that of this module. This module will be removed in 0.20.

  "This module will be removed in 0.20.", DeprecationWarning)
C:\Adaconda2\lib\site-packages\sklearn\learning_curve.py:23: DeprecationWarning: This module was deprecated in version 0.18 in favor of the model_selection module into which all the functions are moved. This module will be removed in 0.20

  DeprecationWarning)


基本的意思是cross_validation和learning_curve模块在0.18版本中被弃用了,在0.20版本中已经被model_selection代替。所以早在导入的时候要从sklearn.model_selection进行导入。

被弃用的模块还有下列一些:

python Warning message:DeprecationWaring

这些模块在之前的版本中被弃用,有利用所有重构的类和函数被一道model_selection模块。

另外,新的CV迭代接口不同于这个模块的接口。这个模块将在0.20中删除。

在调用如果发现导入sklearn.model_selection模块时,找不到该模块,说明需要对adaconda中的sklearn进行更新。

你也可以先在命令窗口查看现在的版本:

输入:conda list

显示结果:

python Warning message:DeprecationWaring

然后使用命令:conda update scikit-learn,对sklearn版本进行更新:

python Warning message:DeprecationWaring

(如果出现conda不是内部外部命令,就是路径问题,将Adaconda-Scripts的路径加入到环境变量就可以了。)

接下来就可以继续编程了。

相关文章: