【发布时间】:2020-05-20 04:41:46
【问题描述】:
我有一个大约 10k 的数据集,我在 sklearn 的 train_test_split 模块中将数据拆分为 80:20 的比例......但是我无法理解输出与添加时与原始数据集不匹配的原因。例如,这是我使用 df.shape (9538, 15) 创建的数据集的大小。现在,如果我把它放入 train_test_split 我会得到类似的东西
from sklearn.model_selection import train_test_split
train, test = train_test_split(df_fake,test_size=0.2, random_state=0)
train, val = train_test_split(df_fake,test_size=0.25,random_state=0)
print('Train-',train.shape)
print('Val-',val.shape)
print('Test-',test.shape)
输出:-
Train- (7153, 15)
Val- (2385, 15)
Test- (1908, 15)
因此,如果我将测试集与验证集添加到 - 4293,当这个数字添加到训练集时,它会变成 11446。而我只有 9.5K 的数据。做错了吗?
【问题讨论】:
-
希望对您有所帮助:datascience.stackexchange.com/questions/15135/…。再次调用
train_test_split时不要传递相同的数据帧,而是传递train
标签: python tensorflow scikit-learn