简体   繁体   English

训练测试拆分函数sklearn中的混洗数据返回错误

[英]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. shuffle : boolean, optional (default=True) 是否在拆分前对数据进行混洗。 If shuffle=False then stratify must be None.如果 shuffle=False 则分层必须为无。

added stratify=None , but I get still the same error.添加了stratify=None ,但我仍然遇到相同的错误。 Any idea how to solve this?知道如何解决这个问题吗?

This is caused by outdated version of sklearn .这是由过时的sklearn版本引起的。 The documentation refers to version 0.19.0.该文档是指版本 0.19.0。 The version of sklearn that is currently installed can be checked by typing可以通过键入来检查当前安装的sklearn的版本

>>> print(sklearn.__version__) 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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