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

Method TestInitWithPredt

tests/cpp/test_learner.cc:569–593  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

567 }
568
569 void TestInitWithPredt() {
570 std::unique_ptr<Learner> learner{Learner::Create({Xy_})};
571 learner->SetParam("objective", "reg:absoluteerror");
572 HostDeviceVector<float> predt;
573 learner->Predict(Xy_, false, &predt, 0, 0);
574
575 auto h_predt = predt.ConstHostSpan();
576 for (auto v : h_predt) {
577 ASSERT_EQ(v, ObjFunction::DefaultBaseScore());
578 }
579
580 Json config(Object{});
581 learner->SaveConfig(&config);
582 auto base_score = GetBaseScore(config);
583 ASSERT_EQ(base_score.size(), 1);
584 ASSERT_EQ(base_score[0], ObjFunction::DefaultBaseScore());
585
586 // since prediction is not used for trianing, the train procedure still runs estimation
587 learner->UpdateOneIter(0, Xy_);
588 learner->SaveConfig(&config);
589 base_score = GetBaseScore(config);
590 ASSERT_EQ(base_score.size(), 1);
591 ASSERT_FALSE(std::isnan(base_score[0]));
592 ASSERT_NE(base_score[0], ObjFunction::DefaultBaseScore());
593 }
594
595 void TestUpdateProcess() {
596 // Check that when training continuation is performed with update, the base score is

Callers 1

TEST_FFunction · 0.80

Calls 7

GetBaseScoreFunction · 0.85
SetParamMethod · 0.80
PredictMethod · 0.80
ConstHostSpanMethod · 0.80
UpdateOneIterMethod · 0.80
SaveConfigMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected