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

Function SplitWithGuaranteedOptimum

library/cpp/grid_creator/binarization.cpp:1022–1044  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1020
1021template <EPenaltyType type>
1022static TQuantization SplitWithGuaranteedOptimum(
1023 TFeatureValues&& features,
1024 const TMaybe<TVector<float>>& initialBorders,
1025 int maxBordersCount,
1026 TMaybe<float> quantizedDefaultBinFraction) {
1027
1028 auto [uniqueFeatureValues, uniqueValueWeights] = GroupAndSortValues(std::move(features), false);
1029 THashSet<float> bordersSet = BestSplit<type>(uniqueFeatureValues, uniqueValueWeights, initialBorders, maxBordersCount);
1030
1031 if (quantizedDefaultBinFraction) {
1032 // reuse uniqueValueWeights for cumulative weights
1033 for (auto i : xrange<size_t>(1, uniqueValueWeights.size())) {
1034 uniqueValueWeights[i] += uniqueValueWeights[i - 1];
1035 }
1036 }
1037
1038 return SetQuantizationWithCumulativeWeights(
1039 uniqueFeatureValues,
1040 uniqueValueWeights,
1041 std::move(bordersSet),
1042 quantizedDefaultBinFraction);
1043
1044}
1045
1046static THashSet<float> GenerateMedianBorders(
1047 const TVector<float>& featureValues, const TMaybe<TVector<float>>& initialBorders, int maxBordersCount) {

Callers

nothing calls this directly

Calls 4

GroupAndSortValuesFunction · 0.85
moveFunction · 0.50
sizeMethod · 0.45

Tested by

no test coverage detected