MCPcopy Create free account
hub / github.com/catboost/catboost / SetSeparateInitModel

Method SetSeparateInitModel

catboost/private/libs/algo/learn_context.cpp:637–716  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

635
636
637void 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 );

Callers

nothing calls this directly

Calls 12

CalcCoreModelCheckSumFunction · 0.85
ApplyModelMultiFunction · 0.85
InitApproxFromBaselineFunction · 0.85
xrangeFunction · 0.85
GetTreeCountMethod · 0.45
GetBaselineMethod · 0.45
push_backMethod · 0.45
GetObjectCountMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected