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

Function CheckPairs

catboost/libs/data/target.cpp:180–215  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

178}
179
180static void CheckPairs(TConstArrayRef<TPairInGroup> pairs, const TObjectsGrouping& objectsGrouping) {
181 CB_ENSURE(
182 !objectsGrouping.IsTrivial(),
183 "Pairs in groups are specified, but there's no group info in dataset"
184 );
185
186 for (auto pairIdx : xrange(pairs.size())) {
187 const auto& pairInGroup = pairs[pairIdx];
188 try {
189 CB_ENSURE(
190 pairInGroup.GroupIdx < objectsGrouping.GetGroupCount(),
191 "GroupIdx is not less than total number of groups (" << objectsGrouping.GetGroupCount() << ')'
192 );
193
194 CB_ENSURE(
195 pairInGroup.WinnerIdxInGroup != pairInGroup.LoserIdxInGroup,
196 "WinnerIdxInGroup is equal to LoserIdxInGroup"
197 );
198 ui32 groupSize = objectsGrouping.GetGroup(pairInGroup.GroupIdx).GetSize();
199 auto checkIdx = [&] (auto idx, TStringBuf fieldName) {
200 CB_ENSURE(
201 idx < groupSize,
202 fieldName << " (" << idx << ") > group size (" << groupSize << ')'
203 );
204 };
205 checkIdx(pairInGroup.WinnerIdxInGroup, TStringBuf("WinnerIdxInGroup"));
206 checkIdx(pairInGroup.LoserIdxInGroup, TStringBuf("LoserIdxInGroup"));
207
208 CB_ENSURE(pairInGroup.Weight >= 0.0f, "Weight is negative");
209 } catch (const TCatBoostException& e) {
210 // throw, not ythrow to avoid duplication of line info
211 throw TCatBoostException() << "Pair #" << pairIdx << ' ' << pairInGroup << ": "
212 << e.what();
213 }
214 }
215}
216
217
218void NCB::CheckOneGroupInfo(const TQueryInfo& groupInfo) {

Callers 3

EvalMetricsForUtilsFunction · 0.85
CheckMethod · 0.85
SetPairsMethod · 0.85

Calls 8

xrangeFunction · 0.85
TCatBoostExceptionClass · 0.85
GetGroupCountMethod · 0.80
GetGroupMethod · 0.80
IsTrivialMethod · 0.45
sizeMethod · 0.45
GetSizeMethod · 0.45
whatMethod · 0.45

Tested by

no test coverage detected