ImportError: No module named sklearn.cross_validation
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?
Solution 1:
It must relate to the renaming and deprecation of cross_validation
sub-module to model_selection
. Try substituting cross_validation
to model_selection
Solution 2:
train_test_split is now in model_selection. Just type:
from sklearn.model_selection import train_test_split
it should work
Solution 3:
I guess cross selection is not active anymore. We should use instead model selection. You can write it to run, from sklearn.model_selection import train_test_split
Thats it.