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

Function SortValuesAndInsertDefault

library/cpp/grid_creator/binarization.cpp:1165–1198  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1163
1164
1165static void SortValuesAndInsertDefault(
1166 TFeatureValues& features,
1167 TMaybe<size_t>* defaultValueFirstPos) { // out parameter
1168
1169 if (features.DefaultValue) {
1170 const float defaultValue = features.DefaultValue->Value;
1171 if (features.ValuesSorted) {
1172 auto defaultValueFirstPosIter = LowerBound(
1173 features.Values.begin(),
1174 features.Values.end(),
1175 defaultValue);
1176
1177 *defaultValueFirstPos = defaultValueFirstPosIter - features.Values.begin();
1178
1179 features.Values.insert(defaultValueFirstPosIter, defaultValue);
1180 } else {
1181 features.Values.push_back(defaultValue);
1182 Sort(features.Values);
1183
1184 auto defaultValueFirstPosIter = LowerBound(
1185 features.Values.begin(),
1186 features.Values.end(),
1187 defaultValue);
1188
1189 *defaultValueFirstPos = defaultValueFirstPosIter - features.Values.begin();
1190 }
1191 } else {
1192 if (!features.ValuesSorted) {
1193 Sort(features.Values);
1194 }
1195 *defaultValueFirstPos = Nothing();
1196 }
1197 features.ValuesSorted = true;
1198}
1199
1200
1201TQuantization TMedianBinarizer::BestSplit(

Callers 1

BestSplitMethod · 0.85

Calls 7

LowerBoundFunction · 0.85
NothingFunction · 0.85
SortFunction · 0.50
beginMethod · 0.45
endMethod · 0.45
insertMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected