ModuleNotFoundError: No module named 'sklearn.cross_validation' site:stackoverflow.com code example

Example 1: ModuleNotFoundError: No module named 'sklearn.cross_validation'

Substitute cross_validation to model_selection

Example 2: No module named 'sklearn.cross_validation'

#Substitute cross_validation to model_selection
from sklearn.model_selection import train_test_split

Example 3: ModuleNotFoundError: No module named 'sklearn.cross_validation'

ImportError: No module named sklearn.cross_validation

Example 4: ModuleNotFoundError: No module named 'sklearn.cross_validation'

#train_test_split is now in model_selection. Just type:

from sklearn.model_selection import train_test_split
#it should work