Scikit-learn: sklearn.cross_validation LabelKFold gives warnings and erros

Created on 7 Jul 2016  路  3Comments  路  Source: scikit-learn/scikit-learn

Cloned sklearn today 7-7-2016

sklearn.version
'0.18.dev0'

from sklearn.cross_validation import train_test_split, LabelKFold
'''.......DeprecationWarning'''
a=LabelKFold(4)
TypeError: object of type 'int' has no len()
a=LabelKFold(n_folds=4)
TypeError: __init__() takes at least 2 arguments (2 given)

There will be no problem if :

from sklearn.model_selection import LabelKFold

Most helpful comment

Just replace 'from sklearn.cross_validation import train_test_split, LabelKFold' with 'from sklearn.from sklearn.model_selection import train_test_split, LabelKFold'

All 3 comments

What code includes from sklearn.cross_validation import train_test_split, LabelKFold?

OK, I think this is not a problem as the warning message already indicate the differences of two LabelKFold method.

from sklearn.cross_validation import train_test_split, LabelKFold
/usr/local/lib/python2.7/dist-packages/sklearn/cross_validation.py:43: DeprecationWarning: This module has been deprecated 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)

Just replace 'from sklearn.cross_validation import train_test_split, LabelKFold' with 'from sklearn.from sklearn.model_selection import train_test_split, LabelKFold'

Was this page helpful?
0 / 5 - 0 ratings