. Advertisement .
..3..
. Advertisement .
..4..
As the title says, I am getting the “no module named ‘sklearn.cross_validation’” error when I am trying to access a method from the cross-validation module:
from sklearn.cross_validation import train_test_split
Then it returns me following error:
ImportError: No module named sklearn.cross_validation
I need to find a solution for this error. Could you give me some advice?
The cause: You get this error when you try to import functions or classes from the c
ross_validation
module instead of themodel_selection
module. In Scikit-Learn, the cross validation module is no longer available.The solution:
Model_selection
should be used instead ofcross_validation
.The renaming and deprecation of the cross validation sub-module to model selection could be the cause of this problem.
cross_validation
was deprecated in version 0.18 and was changed tomodel_selection
from version 0.20 onwards.Instead of
cross_validation
, importmodel_selection
as the following: