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

Function RegularBorder

library/cpp/grid_creator/binarization.cpp:698–731  ·  view source on GitHub ↗

Border before element with value "border"

Source from the content-addressed store, hash-verified

696
697// Border before element with value "border"
698static float RegularBorder(float border, const TVector<float>& sortedValues, const TMaybe<TVector<float>>& initialBorders) {
699 TVector<float>::const_iterator lowerBound = LowerBound(sortedValues.begin(), sortedValues.end(), border);
700
701 if (lowerBound == sortedValues.end()) { // binarizing to always false
702 if (initialBorders && !initialBorders->empty()) {
703 if (sortedValues.back() < initialBorders->back()) {
704 return initialBorders->back();
705 }
706 }
707 return Max(2.f * sortedValues.back(), sortedValues.back() + 1.f);
708 }
709
710 if (lowerBound == sortedValues.begin()) {// binarizing to always true
711 if (initialBorders && !initialBorders->empty()) {
712 if ((*initialBorders)[0] <= sortedValues.back()) {
713 return (*initialBorders)[0];
714 }
715 }
716 return Min(.5f * sortedValues.front(), 2.f * sortedValues.front());
717 }
718
719 if (initialBorders) {
720 const auto possibleBorder = UpperBound(initialBorders->begin(), initialBorders->end(), lowerBound[-1]);
721 if (possibleBorder != initialBorders->end() && (*possibleBorder) <= lowerBound[0]) {
722 return (*possibleBorder);
723 }
724 }
725
726 float res = (lowerBound[0] + lowerBound[-1]) * .5f;
727 if (res == lowerBound[0]) { // wrong side rounding (should be very scarce)
728 res = lowerBound[-1];
729 }
730 return res;
731}
732
733
734namespace {

Callers 3

GenerateMedianBordersFunction · 0.85
BestSplitMethod · 0.85

Calls 9

LowerBoundFunction · 0.85
UpperBoundFunction · 0.85
MaxFunction · 0.50
MinFunction · 0.50
beginMethod · 0.45
endMethod · 0.45
emptyMethod · 0.45
backMethod · 0.45
frontMethod · 0.45

Tested by

no test coverage detected