-
-
Notifications
You must be signed in to change notification settings - Fork 26.2k
Description
When I run the following code:
from sklearn.model_selection import train_test_split
X_train, X_rest, y_train, y_rest = train_test_split(x, y, stratify=None,test_size=0.4)
I get this error:
TypeError Traceback (most recent call last)
in
3 #from sklearn.cross_validation import train_test_split
4
----> 5 X_train, X_test, y_train, y_test = train_test_split(x, y, test_size=0.2, stratify=y, random_state=123, shuffle=True)
6
7 # X_train, X_rest, y_train, y_rest = train_test_split(x, y, stratify=None,test_size=0.4)
~\anaconda3\lib\site-packages\sklearn\model_selection_split.py in train_test_split(*arrays, **options)
2152 train, test = next(cv.split(X=arrays[0], y=stratify))
2153
-> 2154 return list(chain.from_iterable((_safe_indexing(a, train),
2155 _safe_indexing(a, test)) for a in arrays))
2156
~\anaconda3\lib\site-packages\sklearn\model_selection_split.py in (.0)
2152 train, test = next(cv.split(X=arrays[0], y=stratify))
2153
-> 2154 return list(chain.from_iterable((_safe_indexing(a, train),
2155 _safe_indexing(a, test)) for a in arrays))
2156
~\anaconda3\lib\site-packages\sklearn\utils_init_.py in _safe_indexing(X, indices, axis)
393 return _pandas_indexing(X, indices, indices_dtype, axis=axis)
394 elif hasattr(X, "shape"):
--> 395 return _array_indexing(X, indices, indices_dtype, axis=axis)
396 else:
397 return _list_indexing(X, indices, indices_dtype)
~\anaconda3\lib\site-packages\sklearn\utils_init_.py in _array_indexing(array, key, key_dtype, axis)
172 def _array_indexing(array, key, key_dtype, axis):
173 """Index an array or scipy.sparse consistently across NumPy version."""
--> 174 if np_version < parse_version('1.12') or issparse(array):
175 # FIXME: Remove the check for NumPy when using >= 1.12
176 # check if we have an boolean array-likes to make the proper indexing
TypeError: '<' not supported between instances of 'tuple' and 'Version'
It looks like Version was a tuple before (therefore, was comparable with ordinary touples)