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

Method RunTest

tests/cpp/test_multi_target.cc:70–105  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

68 }
69
70 void RunTest(Context const* ctx, std::string const& tree_method, bool weight) {
71 auto p_fmat = weight ? Xyw_ : Xy_;
72 std::unique_ptr<Learner> learner{Learner::Create({p_fmat})};
73 learner->SetParams(Args{{"tree_method", tree_method},
74 {"objective", "reg:absoluteerror"},
75 {"device", ctx->DeviceName()}});
76 learner->Configure();
77 for (auto i = 0; i < 4; ++i) {
78 learner->UpdateOneIter(i, p_fmat);
79 }
80 ASSERT_EQ(learner->Groups(), 3);
81
82 Json config{Object{}};
83 learner->SaveConfig(&config);
84 auto base_score = GetBaseScore(config);
85
86 std::vector<float> split_scores;
87 for (bst_target_t t{0}; t < p_fmat->Info().labels.Shape(1); ++t) {
88 auto t_Xy = weight ? single_w_[t] : single_[t];
89 std::unique_ptr<Learner> sl{Learner::Create({t_Xy})};
90 sl->SetParams(Args{{"tree_method", tree_method},
91 {"objective", "reg:absoluteerror"},
92 {"device", ctx->DeviceName()}});
93 sl->Configure();
94 sl->UpdateOneIter(0, t_Xy);
95 Json s_config{Object{}};
96 sl->SaveConfig(&s_config);
97 auto s_base_score = GetBaseScore(s_config);
98 ASSERT_EQ(s_base_score.size(), 1);
99 linalg::Vector<float> out;
100 common::Median(sl->Ctx(), t_Xy->Info().labels, t_Xy->Info().weights_, &out);
101 ASSERT_FLOAT_EQ(s_base_score[0], out(0));
102 split_scores.push_back(s_base_score[0]);
103 }
104 ASSERT_EQ(split_scores, base_score);
105 }
106
107 void RunTest(Context const* ctx, std::string const& tree_method) {
108 this->RunTest(ctx, tree_method, false);

Callers 1

TEST_FFunction · 0.45

Calls 12

GetBaseScoreFunction · 0.85
SetParamsMethod · 0.80
DeviceNameMethod · 0.80
UpdateOneIterMethod · 0.80
ShapeMethod · 0.80
MedianFunction · 0.50
ConfigureMethod · 0.45
GroupsMethod · 0.45
SaveConfigMethod · 0.45
InfoMethod · 0.45
sizeMethod · 0.45
CtxMethod · 0.45

Tested by

no test coverage detected