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

Function GetBucketCount

catboost/private/libs/algo/split.cpp:89–136  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

87
88
89int GetBucketCount(
90 const TSplitEnsemble& splitEnsemble,
91 const NCB::TQuantizedFeaturesInfo& quantizedFeaturesInfo,
92 size_t packedBinaryFeaturesCount,
93 TConstArrayRef<NCB::TExclusiveFeaturesBundle> exclusiveFeaturesBundles,
94 TConstArrayRef<NCB::TFeaturesGroup> featuresGroups
95) {
96 switch (splitEnsemble.Type) {
97 case ESplitEnsembleType::OneFeature:
98 // TSplitCandidate
99 {
100 const auto& splitCandidate = splitEnsemble.SplitCandidate;
101 if (splitCandidate.Type == ESplitType::OnlineCtr) {
102 return splitCandidate.Ctr.BorderCount + 1;
103 } else if ((splitCandidate.Type == ESplitType::FloatFeature) ||
104 (splitCandidate.Type == ESplitType::EstimatedFeature))
105 {
106 return int(
107 quantizedFeaturesInfo.GetBorders(TFloatFeatureIdx(splitCandidate.FeatureIdx)).size()
108 ) + 1;
109 } else {
110 Y_ASSERT(splitCandidate.Type == ESplitType::OneHotFeature);
111 return int(
112 quantizedFeaturesInfo.GetUniqueValuesCounts(TCatFeatureIdx(splitCandidate.FeatureIdx))
113 .OnLearnOnly
114 );
115 }
116 }
117 case ESplitEnsembleType::BinarySplits:
118 {
119 size_t packIdx = splitEnsemble.BinarySplitsPackRef.PackIdx;
120 size_t startIdx = packIdx * sizeof(TBinaryFeaturesPack) * CHAR_BIT;
121 Y_ASSERT(packedBinaryFeaturesCount > startIdx);
122 size_t featuresInPackCount = Min(
123 sizeof(TBinaryFeaturesPack) * CHAR_BIT,
124 packedBinaryFeaturesCount - startIdx
125 );
126 return int(1u << featuresInPackCount);
127 }
128 case ESplitEnsembleType::ExclusiveBundle:
129 return exclusiveFeaturesBundles[splitEnsemble.ExclusiveFeaturesBundleRef.BundleIdx].GetBinCount();
130 case ESplitEnsembleType::FeaturesGroup:
131 return featuresGroups[splitEnsemble.FeaturesGroupRef.GroupIdx].TotalBucketCount;
132 default:
133 CB_ENSURE(false, "Unexpected split ensemble type");
134 }
135 Y_UNREACHABLE();
136}

Callers 3

TSubtractTrickInfoMethod · 0.85
CalcStatsAndScoresFunction · 0.85

Calls 5

MinFunction · 0.50
sizeMethod · 0.45
GetBordersMethod · 0.45
GetUniqueValuesCountsMethod · 0.45
GetBinCountMethod · 0.45

Tested by

no test coverage detected