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

Method SetUp

tests/cpp/test_serialization.cc:660–678  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

658 size_t constexpr static kClasses = 4;
659
660 void SetUp() override {
661 p_dmat_ = RandomDataGenerator(kRows, kCols, .5f).GenerateDMatrix();
662
663 std::shared_ptr<DMatrix> p_dmat{p_dmat_};
664 p_dmat->Info().labels.Reshape(kRows);
665 auto& h_labels = p_dmat->Info().labels.Data()->HostVector();
666
667 std::uniform_int_distribution<size_t> categorical(0, kClasses - 1);
668 std::mt19937 rnd{0};
669
670 for (auto& v : h_labels) {
671 v = categorical(rnd);
672 }
673
674 for (size_t i = 0; i < kCols; ++i) {
675 std::string name = "feat_" + std::to_string(i);
676 fmap_.PushBack(i, name.c_str(), "q");
677 }
678 }
679};
680
681TEST_F(MultiClassesSerializationTest, Exact) {

Callers

nothing calls this directly

Calls 7

RandomDataGeneratorClass · 0.85
GenerateDMatrixMethod · 0.80
ReshapeMethod · 0.80
PushBackMethod · 0.80
c_strMethod · 0.80
InfoMethod · 0.45
DataMethod · 0.45

Tested by

no test coverage detected