The Python Oracle

ImportError: No module named sklearn.cross_validation

--------------------------------------------------
Rise to the top 3% as a developer or hire one of them at Toptal: https://topt.al/25cXVn
--------------------------------------------------

Music by Eric Matyas
https://www.soundimage.org
Track title: Hypnotic Puzzle3

--

Chapters
00:00 Importerror: No Module Named Sklearn.Cross_validation
00:34 Answer 1 Score 36
00:55 Accepted Answer Score 821
01:09 Answer 3 Score 189
01:24 Answer 4 Score 45
01:41 Thank you

--

Full question
https://stackoverflow.com/questions/3066...

--

Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...

--

Tags
#python #scikitlearn

#avk47



ACCEPTED ANSWER

Score 821


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




ANSWER 2

Score 189


train_test_split is now in model_selection. Just type:

from sklearn.model_selection import train_test_split

it should work




ANSWER 3

Score 45


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.




ANSWER 4

Score 36


Make sure you have Anaconda installed and then create a virtualenv using conda. This will ensure all the imports work

Python 2.7.9 |Anaconda 2.2.0 (64-bit)| (default, Mar  9 2015, 16:20:48) 
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
Anaconda is brought to you by Continuum Analytics.
Please check out: http://continuum.io/thanks and https://binstar.org
>>> from sklearn.cross_validation import train_test_split