LoginSignup
0
0

More than 3 years have passed since last update.

scikit-learnバージョンアップ時の移行メモ(cross_validation)

Last updated at Posted at 2019-07-02

はじめに

scikit-learnを0.19.2から0.21にバージョンアップしたところ以下のエラーがでて動かなかったため簡易に対応した時のメモ

from sklearn import svm, tree, cross_validation
ImportError: cannot import name 'cross_validation' from 'sklearn' 

対応方法

動かなくなっていたのは、以下のようにcross_valdiationモジュールの関数を呼び出していたところ。
このモジュールに含まれていたcross_val_predict関数は、sklearn.model_selectionモジュールに移動になっているとのこと。

cross_validation.cross_val_predict(pls_result, x, y, cv=fn)

そこで以下のように既存のcross_validationモジュールの読み込みをコメントオフにし、
sklearn.model_selectionモジュールを "cross_validation"として別名で読み込んであればよい。

#from sklearn import cross_validation
import sklearn.model_selection as cross_validation

わずか1行で移行完了!

0
0
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
0
0