Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

DeprecationWarning on 0.18.1 when importing GridSearchCV

I have a scikit-learn installation version 0.18.1::

$ pip uninstall -y scipy scikit-learn $ pip install scipy scikit-learn

When I import GridSearchCV I get a strange DeprecationWarning::

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

If I run it I get::

(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

How to avoid this deprecation warning ?

like image 243
Náthali Avatar asked Mar 23 '17 18:03

Náthali


1 Answers

The deprecation warning is a bit misleading. GridSearchCV is not going away as @abccd suggested, it is being moved to a different submodule within scikit-learn.

Instead of:

from sklearn.grid_search import GridSearchCV

Use:

from sklearn.model_selection import GridSearchCV
like image 188
James Avatar answered Nov 02 '22 12:11

James