python由于版本问题而出现的几个常见Warning及解决方法

      • 1警告一交叉验证库
      • 2警告二主成分分析PCA库
      • 3警告三调试参数函数

1、警告一:交叉验证库

源码为:
from sklearn.cross_validation import train_test_split
对应警告信息为:
D:\python35\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.
应该将源码修改为:
from sklearn.model_selection import train_test_split

2、警告二:主成分分析PCA库

源码为:
from sklearn.decomposition import RandomizedPCA
对应警告信息为:
D:\python35\lib\site-packages\sklearn\grid_search.py:43: 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. This module will be removed in 0.20.
DeprecationWarning)
应该将源码改为:
from sklearn.decompostion import PCA

3、警告三:调试参数函数

源码为:
from sklearn.grid_serarch import GridSearchCV
警告信息为:
D:\python35\lib\site-packages\sklearn\utils\deprecation.py:52: DeprecationWarning: Class RandomizedPCA is deprecated; RandomizedPCA was deprecated in 0.18 and will be removed in 0.20\. Use PCA(svd_solver='randomized') instead. The new implementation DOES NOT store whiten ``components_``. Apply transform to get them.
warnings.warn(msg, category=DeprecationWarning)
应该将源码改为:
from sklearn.modelselection import GridSearchCV

你可能感兴趣的:(python测试)