Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Deprecation warnings from sklearn

Tags:

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.

like image 424
Biranchi Avatar asked Apr 09 '17 02:04

Biranchi


People also ask

How do you stop Sklearn warnings?

If you wish to squelch deprecation warnings, you can start Python with -Wi::Deprecation . This sets all deprecation warnings to ignored. There is also an Scikit-beam-specific ~scikit-beam. utils.

How do I stop deprecation warning in Python?

If you wish to squelch deprecation warnings, you can start Python with -Wi::Deprecation. This sets all deprecation warnings to ignored. There is also an Astropy-specific AstropyDeprecationWarning which can be used to disable deprecation warnings from Astropy only.

What is deprecation warning?

Deprecation warnings are a common thing in our industry. They are warnings that notify us that a specific feature (e.g. a method) will be removed soon (usually in the next minor or major version) and should be replaced with something else.


2 Answers

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.

like image 53
cjbrog Avatar answered Sep 17 '22 17:09

cjbrog


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)

like image 44
Roshan Bagdiya Avatar answered Sep 17 '22 17:09

Roshan Bagdiya