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

Method GetTreeLeafCounts

catboost/libs/model/model.cpp:676–693  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

674}
675
676TVector<ui32> TModelTrees::GetTreeLeafCounts() const {
677 auto applyData = GetApplyData();
678 const auto& firstLeafOfsets = applyData->TreeFirstLeafOffsets;
679 Y_ASSERT(IsSorted(firstLeafOfsets.begin(), firstLeafOfsets.end()));
680 TVector<ui32> treeLeafCounts;
681 treeLeafCounts.reserve(GetTreeCount());
682 for (size_t treeNum = 0; treeNum < GetTreeCount(); ++treeNum) {
683 const size_t currTreeLeafValuesEnd = (
684 treeNum + 1 < GetTreeCount()
685 ? firstLeafOfsets[treeNum + 1]
686 : GetModelTreeData()->GetLeafValues().size()
687 );
688 const size_t currTreeLeafValuesCount = currTreeLeafValuesEnd - firstLeafOfsets[treeNum];
689 Y_ASSERT(currTreeLeafValuesCount % ApproxDimension == 0);
690 treeLeafCounts.push_back(currTreeLeafValuesCount / ApproxDimension);
691 }
692 return treeLeafCounts;
693}
694
695void TModelTrees::SetScaleAndBias(const TScaleAndBias& scaleAndBias) {
696 CB_ENSURE(IsValidFloat(scaleAndBias.Scale), "Invalid scale " << scaleAndBias.Scale);

Callers 2

AlmostEqualLeafValuesMethod · 0.80
MakeCatBoostImporterFunction · 0.80

Calls 8

IsSortedFunction · 0.85
GetTreeCountFunction · 0.85
beginMethod · 0.45
endMethod · 0.45
reserveMethod · 0.45
sizeMethod · 0.45
GetLeafValuesMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected