How to fix ModuleNotFoundError: No module named ‘sklearn.cross_validation’ ?

If you are getting the below error,

Traceback (most recent call last):
File “regression.py”, line 14, in
from sklearn.cross_validation import train_test_split
ModuleNotFoundError: No module named ‘sklearn.cross_validation’

Don’t worry, you can fix it very easily.

You might have imported train_test_split as shown below

from sklearn.cross_validation import train_test_split

Replace that with

from sklearn.model_selection import train_test_split

That will fix it 🙂

How to fix ModuleNotFoundError: No module named ‘sklearn.cross_validation’ ?

Leave a Reply

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

Scroll to top