【发布时间】:2021-05-09 09:37:27
【问题描述】:
我有一个包含多个标签的数据集,即每个 X 我有 2 个 y,我需要分成训练集和测试集。
我尝试使用 sklearn 函数 train_test_split():
import numpy as np
from sklearn.model_selection import train_test_split
X = np.random.randn(10)
y1 = np.random.randint(1,10,10)
y2 = np.random.randint(1,3,10)
X_train, X_test, [Y1_train, Y2_train], [Y1_test, Y2_test] = train_test_split(X, [y1, y2], test_size=0.4, random_state=42)
但我收到一条错误消息:
ValueError: Found input variables with inconsistent numbers of samples: [10, 2]
【问题讨论】:
标签: python numpy scikit-learn train-test-split