解决弃用警告:This module was deprecated in version 0.18 in favor of the model_selection modul into which a

弃用警告消除

在pycharm中导入sklearn.cross_validation模块时,发现以下warning而不是error,说明程序虽然可以正常使用但是有警告出现:

from sklearn.cross_validation import train_test_split
C:\Users\Admin\Anaconda3\lib\site-packages\sklearn\cross_validation.py:41: 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)

DeprecationWarning(弃用警告): 这个模块是0.18版本不支持的model_selection模块的所有类和函数的重构移动。还要注意,新的CV迭代器的接口与此模块的接口不同。此模块将在0.20中删除。
“本模块将在0.20版本中被删除,弃用警告)。

因此是版本问题造成的不兼容。

于是我们将cross_validation改成model_selection

from sklearn.model_selection import train_test_split

成功解决问题。

你可能感兴趣的:(warning&error)