Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ImportError: cannot import name 'cross_validation' from 'sklearn' [duplicate]

Here is my code Please Help. I'm a beginner.

    import pandas as pd     import sklearn     from sklearn.feature_selection import SelectFromModel     from sklearn.ensemble import ExtraTreesClassifier     from sklearn.metrics import confusion_matrix     from sklearn.model_selection import train_test_split     from sklearn import cross_validation 

I'm using the latest version of Sklearn but I'm getting this error

On Windows:

Traceback (most recent call last): File "MalwareDetector.py", line 8, in from sklearn import cross_val_score ImportError: cannot import name 'cross_val_score' from 'sklearn' (C:\Users\richa\AppData\Local\Programs\Python\Python37-32\lib\site-packages\sklearn__init__.py)

On Ubuntu:

Traceback (most recent call last): File "MalwareDetector.py", line 8, in from sklearn import cross_validation ImportError: cannot import name cross_validation

like image 794
Richard Phillips Roy Avatar asked Dec 30 '18 15:12

Richard Phillips Roy


1 Answers

cross_validation is deprecated since version 0.18. This module will be removed in 0.20.

Use sklearn.model_selection.train_test_split instead.

from sklearn.model_selection import train_test_split 

More: sklearn 0.19 docs

like image 163
Eder Avatar answered Sep 18 '22 15:09

Eder