ImportError: cannot import name ‘cross_validation’ from ‘sklearn’

Using sklearn (scikit learn) import cross_ An error is reported during validation as follows:

ImportError: cannot import name ‘cross_ validation’ from ‘sklearn’ 

The original code is:

from sklearn import cross_validation as cv

reason:

sklearn.cross_ Validation is a module in the old version of sklearn

The new versions are all migrated to sklearn.model_ selection

The solution will be

cross_ Replace validation with “model”_ selection

from sklearn import model_selection as cv

Problem solving.

Read More: