■
Pythonによるスクレイピング&機械学習 開発テクニック BeautifulSoup,scikit-learn,TensorFlowを使ってみよう
- 作者: クジラ飛行机
- 出版社/メーカー: ソシム
- 発売日: 2016/12/06
- メディア: 単行本
- この商品を含むブログ (3件) を見る
書籍どおり進めるとp.179のSVMを動かすときに警告がでる。cross_validationモジュールは非推奨で、バージョン0.20で機能がなくなるとのこと。
/xxxxx/anaconda/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)
VSCodeの警告のアンダー部分をクリックすると、cross_validation.pyにとばされるので、以下のとおり変更したら警告が非表示になった。
#from sklearn import cross_validation, svm, metrics from sklearn import model_selection, svm, metrics
#data_train, data_test, label_train, label_test = cross_validation.train_test_split(wh, label)
data_train, data_test, label_train, label_test = model_selection.train_test_split(wh, label)
p.192のグリッドリサーチも同様に修正して実施したら動いた。
#from sklearn.grid_search import GridSearchCV from sklearn.model_selection import GridSearchCV
ただしFutureWarning:が出る。これはほったらかしてもよさそうなので放置する。
/xxxxx/anaconda/lib/python3.6/site-packages/sklearn/model_selection/_search.py:628: MaskedArrayFutureWarning: setting an item on a masked array which has a shared mask will not copy the mask and also change the original mask array in the future. Check the NumPy 1.11 release notes for more information.