简体   繁体   中英

shuffle data in train test split function sklearn returns error

import numpy as np
from sklearn.cross_validation import train_test_split as tts

a = np.array([[1,2,3,4,5]]).T
b = np.array([[100,200,50,60,3000]]).T

x1,x2,y1,y2 = tts(a,b, test_size=0.2, shuffle=False)

print(x1)
print(x2)
print(y1)
print(y2)

I always receive following error:

builtins.TypeError: Invalid parameters passed: {'shuffle': False}

I have checked documentation:

shuffle : boolean, optional (default=True) Whether or not to shuffle the data before splitting. If shuffle=False then stratify must be None.

added stratify=None , but I get still the same error. Any idea how to solve this?

This is caused by outdated version of sklearn . The documentation refers to version 0.19.0. The version of sklearn that is currently installed can be checked by typing

>>> print(sklearn.__version__) 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM