2017-03-23 55 views
3

時,我有一個scikit學習安裝版本0.18.1 ::DeprecationWarning在0.18.1進口GridSearchCV

$ PIP卸載-y SciPy的scikit學習 $ PIP安裝SciPy的scikit學習

當我進口GridSearchCV我得到一個奇怪的DeprecationWarning ::

(venv2) :~/$ cat warn.pyy 
from sklearn.grid_search import GridSearchCV 
import sklearn as sk 
print(sk.__version__) 

如果我運行它,我得到::

(venv2) :~/$ python warn.py 
/home/n/venv2/local/lib/python2.7/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) 
/home/n/venv2/local/lib/python2.7/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) 

0.18.1 

如何避免此棄用警告?

回答

5

棄用警告有點令人誤解。 GridSearchCV不會像@abccd建議的那樣離開,它將被移到scikit-learn中的不同子模塊中。

相反的:

from sklearn.grid_search import GridSearchCV 

用途:

from sklearn.model_selection import GridSearchCV