scikit-learn 0.18中的cross_validation模塊被移除


環境:scikit-learn 0.18 , python3

from sklearn.cross_validation import train_test_split from sklearn.grid_search import GridSearchCV 

報出如下警告:

from sklearn.grid_search import GridSearchCV 
/usr/lib/python3.4/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) 
/usr/lib/python3.4/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.cross_validation import 
train_test_split 
/usr/lib/python3.4/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)

解決方法:

該模塊在0.18版本中被棄用,支持所有重構的類和函數都被移動到的model_selection模塊

from sklearn.model_selection import GridSearchCV from sklearn.model_selection import train_test_split

警告

DeprecationWarning) 
/usr/lib/python3.4/site-packages/sklearn/utils/validation.py:395: 
DeprecationWarning: Passing 1d arrays as data is deprecated in 0.17 
and will raise ValueError in 0.19. Reshape your data either using 
X.reshape(-1, 1) if your data has a single feature or X.reshape(1, -1) 
if it contains a single sample.

解決方法

clf.predict([]) 規范輸入


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM