【发布时间】:2019-09-29 15:43:52
【问题描述】:
基本上,我想将我的数据集拆分为训练、测试和验证集。因此,我两次使用了 train_test_split 函数。我有一个大约 1000 万行的数据集。
在第一次拆分时,我将训练和测试数据集拆分为 7000 万个训练和 3000 万个测试。现在要获得验证集,我有点困惑是否使用拆分的测试数据或训练数据作为 train-test-split 的输入参数以获得验证集。给点建议。 TIA
X = features
y = target
# dividing X, y into train and test and validation data 70% training dataset with 15% testing and 15% validation set
from sklearn.model_selection import train_test_split
#features and label splitted into 70-30
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size = 0.3, random_state = 0)
#furthermore test data is splitted into test and validation set 15-15
x_test, x_val, y_test, y_val = train_test_split(X_test, y_test, test_size=0.5)
【问题讨论】:
-
看看这个
sklearn.model_selection.StratifiedShuffleSplit
标签: python machine-learning classification train-test-split