| 635 | |
| 636 | |
| 637 | void TLearnProgress::SetSeparateInitModel( |
| 638 | const TFullModel& initModel, |
| 639 | const TDataProviders& initModelApplyCompatiblePools, |
| 640 | bool isOrderedBoosting, |
| 641 | bool storeExpApproxes, |
| 642 | NPar::ILocalExecutor* localExecutor) { |
| 643 | |
| 644 | CATBOOST_DEBUG_LOG << "TLearnProgress::SetSeparateInitModel\n"; |
| 645 | |
| 646 | SeparateInitModelTreesSize = SafeIntegerCast<ui32>(initModel.GetTreeCount()); |
| 647 | SeparateInitModelCheckSum = CalcCoreModelCheckSum(initModel); |
| 648 | |
| 649 | // Calc approxes |
| 650 | |
| 651 | auto calcApproxFunction = [&] (const TDataProvider& data) -> TVector<TVector<double>> { |
| 652 | return ApplyModelMulti( |
| 653 | initModel, |
| 654 | *data.ObjectsData, |
| 655 | EPredictionType::RawFormulaVal, |
| 656 | 0, |
| 657 | SafeIntegerCast<int>(initModel.GetTreeCount()), |
| 658 | localExecutor, |
| 659 | data.RawTargetData.GetBaseline() |
| 660 | ); |
| 661 | }; |
| 662 | |
| 663 | TVector<std::function<void()>> tasks; |
| 664 | |
| 665 | tasks.push_back( |
| 666 | [&] () { |
| 667 | const ui32 learnObjectCount = initModelApplyCompatiblePools.Learn->GetObjectCount(); |
| 668 | if (!learnObjectCount) { |
| 669 | return; |
| 670 | } |
| 671 | |
| 672 | AvrgApprox = calcApproxFunction(*initModelApplyCompatiblePools.Learn); |
| 673 | |
| 674 | TVector<TConstArrayRef<double>> approxRef(AvrgApprox.begin(), AvrgApprox.end()); |
| 675 | |
| 676 | TVector<std::function<void()>> tasks; |
| 677 | |
| 678 | auto setFoldApproxes = [&] (bool isPlainFold, TFold* fold) { |
| 679 | for (auto& bodyTail : fold->BodyTailArr) { |
| 680 | InitApproxFromBaseline( |
| 681 | isPlainFold ? learnObjectCount : SafeIntegerCast<ui32>(bodyTail.TailFinish), |
| 682 | TConstArrayRef<TConstArrayRef<double>>(approxRef), |
| 683 | fold->GetLearnPermutationArray(), |
| 684 | storeExpApproxes, |
| 685 | &bodyTail.Approx); |
| 686 | } |
| 687 | }; |
| 688 | |
| 689 | for (auto foldIdx : xrange(Folds.size())) { |
| 690 | tasks.push_back( |
| 691 | [&, foldIdx] () { |
| 692 | setFoldApproxes(!isOrderedBoosting, &Folds[foldIdx]); |
| 693 | } |
| 694 | ); |
nothing calls this directly
no test coverage detected