LoginSignup
13
12

More than 5 years have passed since last update.

Pythonでsklearnのgrid searchが使えないときの対処方法

Last updated at Posted at 2017-07-11

python(ver 3.6.1)でsklearnのgrid searchを使おうと思ってコード書いてコンパイルしたら、なんか引っかかってWarningが出てきました。

↓ソースに書いて、引っかかったところ。

from sklearn.grid_search import GridSearchCV

↓コンパイルして出てきたWarning(ちなみにMacでやってます)

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/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)
/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/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)

Warningを解読すると、モジュールのバージョンが「0.18」から「0.20」に上がったときに削除された模様?
なんやかんやで色々と試したら、pythonのソースの記載をいじって無事に使えるようになりました。

from sklearn.model_selection import GridSearchCV

同じようなところで躓いた方はぜひお試しください!

13
12
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
13
12