我在 3D 数组中有一组图像(尺寸索引 * 高度 * 宽度)。
x_train, x_test, y_train, y_test = train_test_split(X, yy, test_size=0.2, random_state=42, stratify=y)
print(x_train.shape, x_test.shape, y_train.shape, y_test.shape)
dtrain = xgb.DMatrix(data=x_train, label=y_train)
dtest = xgb.DMatrix(data=x_test)
我从 XGBoost DMatrix 输入中得到一个错误:
ValueError: ('Expecting 2 dimensional numpy.ndarray, got: ', (2164, 120, 431))
上面打印的数组的形状:
(2164, 120, 431) (542, 120, 431) (2164, 3) (542, 3)
我对如何重塑数据感到困惑。是否需要为 2164 行 * 1 列?