Reputation: 191
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?
Upvotes: 13
Views: 45187
Reputation: 194
simply replace sklearn.cross_validation with sklearn.model_selection
Upvotes: 2
Reputation: 41
There should be another import:
from sklearn.model_selection import cross_val_score
Upvotes: 2
Reputation: 686
For Sklearn 18 version import this: "from sklearn.cross_validation import KFold"
For sklearn 20 import this: "from sklearn.model_selection import KFold"
Upvotes: 6
Reputation: 14039
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.
Upvotes: 41
Reputation: 855
What's your sklearn version? You can find out with sk.__version__
It's possible that it has been moved to sklearn.model_selection
Upvotes: 7