| 390 | |
| 391 | namespace { |
| 392 | void MakeLabelForTest(std::shared_ptr<DMatrix> Xy, DMatrixHandle cxy) { |
| 393 | auto n_samples = Xy->Info().num_row_; |
| 394 | std::vector<float> y(n_samples); |
| 395 | for (std::size_t i = 0; i < y.size(); ++i) { |
| 396 | y[i] = static_cast<float>(i); |
| 397 | } |
| 398 | |
| 399 | Xy->Info().labels.Reshape(n_samples); |
| 400 | Xy->Info().labels.Data()->HostVector() = y; |
| 401 | |
| 402 | auto y_int = GetArrayInterface(Xy->Info().labels.Data(), n_samples, 1); |
| 403 | std::string s_y_int; |
| 404 | Json::Dump(y_int, &s_y_int); |
| 405 | |
| 406 | XGDMatrixSetInfoFromInterface(cxy, "label", s_y_int.c_str()); |
| 407 | } |
| 408 | |
| 409 | auto MakeSimpleDMatrixForTest(bst_idx_t n_samples, bst_feature_t n_features, Json dconfig) { |
| 410 | HostDeviceVector<float> storage; |
no test coverage detected