| 1020 | |
| 1021 | template <EPenaltyType type> |
| 1022 | static 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 | |
| 1046 | static THashSet<float> GenerateMedianBorders( |
| 1047 | const TVector<float>& featureValues, const TMaybe<TVector<float>>& initialBorders, int maxBordersCount) { |
nothing calls this directly
no test coverage detected