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

Method TestUpdateProcess

tests/cpp/test_learner.cc:595–622  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

593 }
594
595 void TestUpdateProcess() {
596 // Check that when training continuation is performed with update, the base score is
597 // not re-evaluated.
598 std::unique_ptr<Learner> learner{Learner::Create({Xy_})};
599 learner->SetParam("objective", "reg:absoluteerror");
600 learner->Configure();
601
602 learner->UpdateOneIter(0, Xy_);
603 Json model{Object{}};
604 learner->SaveModel(&model);
605 auto base_score = GetBaseScore(model);
606 ASSERT_EQ(base_score.size(), 1);
607 ASSERT_FALSE(std::isnan(base_score[0]));
608
609 auto Xy1 = RandomDataGenerator{100, Cols(), 0}.Seed(321).GenerateDMatrix(true);
610 learner.reset(Learner::Create({Xy1}));
611 learner->LoadModel(model);
612 learner->SetParam("process_type", "update");
613 learner->SetParam("updater", "refresh");
614 learner->UpdateOneIter(1, Xy1);
615
616 Json config(Object{});
617 learner->SaveConfig(&config);
618 auto base_score1 = GetBaseScore(config);
619 ASSERT_EQ(base_score1.size(), 1);
620 ASSERT_FALSE(std::isnan(base_score1[0]));
621 ASSERT_EQ(base_score, base_score1);
622 }
623};
624
625TEST_F(InitBaseScore, TestUpdateConfig) { this->TestUpdateConfig(); }

Callers 1

TEST_FFunction · 0.80

Calls 11

GetBaseScoreFunction · 0.85
SetParamMethod · 0.80
UpdateOneIterMethod · 0.80
GenerateDMatrixMethod · 0.80
SeedMethod · 0.80
ConfigureMethod · 0.45
SaveModelMethod · 0.45
sizeMethod · 0.45
resetMethod · 0.45
LoadModelMethod · 0.45
SaveConfigMethod · 0.45

Tested by

no test coverage detected