| 634 | |
| 635 | class TestColumnSplit : public ::testing::TestWithParam<std::string> { |
| 636 | void TestBaseScore(std::string objective, std::vector<float> const& expected_base_score, |
| 637 | Json expected_model) { |
| 638 | auto const world_size = collective::GetWorldSize(); |
| 639 | auto n_threads = collective::GetWorkerLocalThreads(world_size); |
| 640 | auto const rank = collective::GetRank(); |
| 641 | |
| 642 | std::shared_ptr<DMatrix> p_fmat = MakeFmatForObjTest(objective, 10, 10, 3); |
| 643 | std::shared_ptr<DMatrix> sliced{p_fmat->SliceCol(world_size, rank)}; |
| 644 | std::unique_ptr<Learner> learner{Learner::Create({sliced})}; |
| 645 | learner->SetParams(Args{{"nthread", std::to_string(n_threads)}, |
| 646 | {"tree_method", "approx"}, |
| 647 | {"objective", objective}}); |
| 648 | if (objective.find("quantile") != std::string::npos) { |
| 649 | learner->SetParam("quantile_alpha", "0.5"); |
| 650 | } |
| 651 | if (objective.find("expectile") != std::string::npos) { |
| 652 | learner->SetParam("expectile_alpha", "0.5"); |
| 653 | } |
| 654 | if (objective.find("multi") != std::string::npos) { |
| 655 | learner->SetParam("num_class", "3"); |
| 656 | } |
| 657 | learner->UpdateOneIter(0, sliced); |
| 658 | Json config{Object{}}; |
| 659 | learner->SaveConfig(&config); |
| 660 | auto base_score = GetBaseScore(config); |
| 661 | for (size_t idx = 0; idx < base_score.size(); ++idx) { |
| 662 | ASSERT_NEAR(base_score[idx], expected_base_score[idx], 1e-6); |
| 663 | } |
| 664 | |
| 665 | Json model{Object{}}; |
| 666 | learner->SaveModel(&model); |
| 667 | CompareJsonModels(model, expected_model); |
| 668 | } |
| 669 | |
| 670 | public: |
| 671 | void Run(std::string objective) { |
no test coverage detected