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

Function HasNonZeroApproxForZeroWeightLeaf

catboost/libs/fstr/util.cpp:112–126  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

110}
111
112bool HasNonZeroApproxForZeroWeightLeaf(const TFullModel& model) {
113 for (size_t leafIdx = 0; leafIdx < model.ModelTrees->GetModelTreeData()->GetLeafWeights().size(); ++leafIdx) {
114 size_t approxDimension = model.GetDimensionsCount();
115 if (model.ModelTrees->GetModelTreeData()->GetLeafWeights()[leafIdx] == 0) {
116 double leafSumApprox = 0;
117 for (size_t approxIdx = 0; approxIdx < approxDimension; ++approxIdx) {
118 leafSumApprox += abs(model.ModelTrees->GetModelTreeData()->GetLeafValues()[leafIdx * approxDimension + approxIdx]);
119 }
120 if (leafSumApprox >= 1e-9) {
121 return true;
122 }
123 }
124 }
125 return false;
126}
127
128bool NeedDatasetForLeavesWeights(const TFullModel& model, bool fstrOnTrainPool) {
129 const auto leafWeightsOfModels = model.ModelTrees->GetModelTreeData()->GetLeafWeights();

Callers 3

InitLeafWeightsFunction · 0.85

Calls 5

GetLeafWeightsMethod · 0.80
absFunction · 0.50
sizeMethod · 0.45
GetDimensionsCountMethod · 0.45
GetLeafValuesMethod · 0.45

Tested by

no test coverage detected