[Fixed] no module named ‘sklearn.cross_validation’

In this post, we will see how to resolve error modulenotfounderror: no module named ‘sklearn.cross_validation’ in Python.

Problem: no module named ‘sklearn.cross_validation’

You might get this error even through you have installed scikit-learn correctly on anaconda.

You might get this error in following scneario:

It might return you following error:

Solution: Replace cross_validation with model_selection

This error may be related to renaming and deprecation of cross_validation sub-module to model_selection.

cross_validation was deprecated in version 0.18 and was changed to model_selection from version 0.20 onwards.

You should import model_selection rather than cross_validation as below:

You can refer documents over here: https://scikit-learn.org/stable/modules/cross_validation.html

It should resolve this issue. Please comment in case this solution does not resolve no module named sklearn.cross_validation issue.

That’s all about how to resolve no module named sklearn.cross_validation error in python.

Leave a Reply

Your email address will not be published. Required fields are marked *

Subscribe to our newletter

Get quality tutorials to your inbox. Subscribe now.