Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

No module named 'sklearn.cross_validation'

I'm using anaconda , when I import

import sklearn as sk 

It works but when import :

from sklearn.cross_validation import train_test_split

It returns:

No module named 'sklearn.cross_validation'

I checked the environment and scikit-learn is installed what do I need to do?

like image 242
yousf Avatar asked Feb 16 '19 18:02

yousf


2 Answers

As pointed out by @amit-gupta in the question above, sklearn.cross_validation has been deprecated. The function train_test_split can now be found here:

from sklearn.model_selection import train_test_split

Simply replace the import statement from the question to the one above.

like image 139
Demitri Avatar answered Sep 28 '22 06:09

Demitri


simply replace sklearn.cross_validation with sklearn.model_selection

like image 32
imSantoshKumar Avatar answered Sep 28 '22 07:09

imSantoshKumar