24

I am using cross_validation from sklearn,

from sklearn.cross_validation import train_test_split

I get the below warning:

cross_validation.py:44: DeprecationWarning: This module was deprecated in version 0.18 in favor of the model_selection module into which all the refactored classes and functions are moved.

Ani Menon
  • 27,209
  • 16
  • 105
  • 126
Biranchi
  • 16,120
  • 23
  • 124
  • 161

2 Answers2

51

Problem:

The deprecation warning means that the module is deprecated, i.e. no longer supported. You are using a version for which sklearn.cross_validation is not a module any longer.

Solution:

from sklearn.model_selection import train_test_split

C/O: This post.

cjbrog
  • 786
  • 8
  • 10
5

To avoid this, you just need to replace:

from sklearn.cross_validation import train_test_split 

by

from sklearn.model_selection import train_test_split

Reference: skLearn

Warning: DeprecationWarning: This module was deprecated in version 0.18 in favor of the model_selection module into which all the refactored classes and functions are moved. Also note that the interface of the new CV iterators are different from that of this module. This module will be removed in 0.20. "This module will be removed in 0.20.", DeprecationWarning)

Roshan Bagdiya
  • 2,048
  • 21
  • 41