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

Function MakeSimpleDMatrixForTest

tests/cpp/c_api/test_c_api.cc:409–424  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

407}
408
409auto MakeSimpleDMatrixForTest(bst_idx_t n_samples, bst_feature_t n_features, Json dconfig) {
410 HostDeviceVector<float> storage;
411 auto arr_int = RandomDataGenerator{n_samples, n_features, 0.5f}.GenerateArrayInterface(&storage);
412
413 data::ArrayAdapter adapter{StringView{arr_int}};
414 std::shared_ptr<DMatrix> Xy{
415 DMatrix::Create(&adapter, std::numeric_limits<float>::quiet_NaN(), Context{}.Threads())};
416
417 DMatrixHandle p_fmat;
418 std::string s_dconfig;
419 Json::Dump(dconfig, &s_dconfig);
420 CHECK_EQ(XGDMatrixCreateFromDense(arr_int.c_str(), s_dconfig.c_str(), &p_fmat), 0);
421
422 MakeLabelForTest(Xy, p_fmat);
423 return std::pair{p_fmat, Xy};
424}
425
426auto MakeQDMForTest(Context const *ctx, bst_idx_t n_samples, bst_feature_t n_features,
427 Json dconfig) {

Callers 1

Calls 5

XGDMatrixCreateFromDenseFunction · 0.85
MakeLabelForTestFunction · 0.85
ThreadsMethod · 0.80
c_strMethod · 0.80

Tested by

no test coverage detected