ImportError: No module named sklearn.cross_validation

arthurckl picture arthurckl · Jun 5, 2015 · Viewed 295.8k times · Source

I am using python 2.7 in Ubuntu 14.04. I installed scikit-learn, numpy and matplotlib with these commands:

sudo apt-get install build-essential python-dev python-numpy \
python-numpy-dev python-scipy libatlas-dev g++ python-matplotlib \
ipython

But when I import these packages:

from sklearn.cross_validation import train_test_split

It returns me this error:

ImportError: No module named sklearn.cross_validation

What I need to do?

Answer

Dima Lituiev picture Dima Lituiev · Jan 17, 2016

It must relate to the renaming and deprecation of cross_validation sub-module to model_selection. Try substituting cross_validation to model_selection