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

Function GetRandomDatasetBatch

catboost/libs/fstr/sage_values.cpp:230–277  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

228}
229
230TDataProvider GetRandomDatasetBatch(
231 const TDataProvider& dataset,
232 size_t batchSize,
233 TRestorableFastRng64* randPtr,
234 NPar::ILocalExecutor* localExecutor)
235{
236 if (dataset.ObjectsGrouping->IsTrivial()) {
237 TVector<ui32> indices(dataset.GetObjectCount());
238 Iota(indices.begin(), indices.end(), 0);
239 PartialShuffle(indices.begin(), indices.end(), batchSize, *randPtr);
240
241 auto subset = dataset.GetSubset(
242 GetSubset(
243 dataset.ObjectsGrouping.Get(),
244 std::move(TArraySubsetIndexing<ui32>(TVector<ui32>(indices.begin(), indices.begin() + batchSize))),
245 EObjectsOrder::Ordered
246 ),
247 GetMonopolisticFreeCpuRam(),
248 localExecutor
249 );
250
251 return *subset;
252 } else {
253 TVector<ui32> groupIndices(dataset.ObjectsGrouping->GetGroupCount());
254 Iota(groupIndices.begin(), groupIndices.end(), 0);
255 Shuffle(groupIndices.begin(), groupIndices.end(), *randPtr);
256
257 TVector<ui32> batchGroupIndices;
258 ui32 realBatchSize = 0;
259 ui32 groupShuffledIndex = 0;
260 while (realBatchSize < batchSize) {
261 realBatchSize += dataset.ObjectsGrouping->GetGroup(groupIndices[groupShuffledIndex]).GetSize();
262 ++groupShuffledIndex;
263 }
264
265 auto subset = dataset.GetSubset(
266 GetSubset(
267 dataset.ObjectsGrouping.Get(),
268 std::move(TArraySubsetIndexing<ui32>(TVector<ui32>(groupIndices.begin(), groupIndices.begin() + groupShuffledIndex))),
269 EObjectsOrder::Ordered
270 ),
271 GetMonopolisticFreeCpuRam(),
272 localExecutor
273 );
274
275 return *subset;
276 }
277}
278
279double CalculateModelLoss(
280 const TFullModel& model,

Callers 1

CalcSageValuesFunction · 0.85

Calls 15

IotaFunction · 0.85
PartialShuffleFunction · 0.85
GetSubsetFunction · 0.85
GetGroupCountMethod · 0.80
GetGroupMethod · 0.80
moveFunction · 0.50
ShuffleFunction · 0.50
IsTrivialMethod · 0.45
GetObjectCountMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected