如何将标签传递给 XGBoost JVM 包的矩阵

How to pass label to matrix of XGBoost JVM Package

我在 official doc

找到了创建数据矩阵的 JVM 包快速入门示例
float[] data = new float[] {1f,2f,3f,4f,5f,6f};
int nrow = 3;
int ncol = 2;
float missing = 0.0f;
DMatrix dmat = new DMatrix(data, nrow, ncol, missing);

// and a DMatrix could be called by train method
Booster booster = XGBoost.train(dmat, params, nround, watches, null, null);

然而,文档说JVM包DMatrix用法与Python包相同,在Python中有一个标签参数

dtrain = xgb.DMatrix(data, label=label)

但是在JVM包里找不到,怎么设置标签?

在 XGBoost JVM 包中,我们可以使用 dMatrix.setLabel(labelArray) 设置标签(根据 XGBoost github issue page)