| 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 |
no test coverage detected