MCPcopy Create free account
hub / github.com/dmlc/xgboost / MakeLabelForTest

Function MakeLabelForTest

tests/cpp/c_api/test_c_api.cc:392–407  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

390
391namespace {
392void 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
409auto MakeSimpleDMatrixForTest(bst_idx_t n_samples, bst_feature_t n_features, Json dconfig) {
410 HostDeviceVector<float> storage;

Callers 2

MakeSimpleDMatrixForTestFunction · 0.85
MakeExtMemForTestFunction · 0.85

Calls 7

GetArrayInterfaceFunction · 0.85
ReshapeMethod · 0.80
c_strMethod · 0.80
InfoMethod · 0.45
sizeMethod · 0.45
DataMethod · 0.45

Tested by

no test coverage detected