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

Function MapGenericRemoteCalcScore

catboost/private/libs/distributed/master.cpp:326–375  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

324
325template <typename TBinCalcMapper, typename TScoreCalcMapper>
326void MapGenericRemoteCalcScore(
327 double scoreStDev,
328 TVector<TCandidatesContext>* candidatesContexts,
329 TLearnContext* ctx) {
330
331 Y_ASSERT(ctx->Params.SystemOptions->IsMaster());
332
333 auto scoreDistribution = GetScoreDistribution(ctx->Params.ObliviousTreeOptions->RandomScoreType);
334
335 // Flatten candidateLists from all contexts to ensure even parallelization
336 TCandidateList allCandidatesList;
337 for (auto& candidatesContext : *candidatesContexts) {
338 allCandidatesList.insert(
339 allCandidatesList.end(),
340 candidatesContext.CandidateList.begin(),
341 candidatesContext.CandidateList.end());
342 }
343
344 NPar::TJobDescription job;
345 NPar::Map(&job, new TBinCalcMapper(), &allCandidatesList);
346 NPar::RemoteMap(&job, new TScoreCalcMapper);
347 NPar::TJobExecutor exec(&job, TMasterEnvironment::GetRef().SharedTrainData);
348 TVector<typename TScoreCalcMapper::TOutput> allScores;
349 exec.GetRemoteMapResults(&allScores);
350 // set best split for each candidate
351 Y_ASSERT(allCandidatesList.size() == allScores.size());
352 const ui64 randSeed = ctx->LearnProgress->Rand.GenRand();
353
354 size_t allScoresOffset = 0;
355 for (auto& candidatesContext : *candidatesContexts) {
356 auto& candidateList = candidatesContext.CandidateList;
357 ctx->LocalExecutor->ExecRange(
358 [&] (int candidateIdx) {
359 auto& candidates = candidateList[candidateIdx].Candidates;
360 CB_ENSURE(candidates.size() > 0, "Some score calcer did not produce ay scores");
361
362 SetBestScore(
363 randSeed + candidateIdx,
364 allScores[allScoresOffset + candidateIdx],
365 scoreDistribution,
366 scoreStDev,
367 candidatesContext,
368 &candidates);
369 },
370 0,
371 candidateList.ysize(),
372 NPar::TLocalExecutor::WAIT_COMPLETE);
373 allScoresOffset += candidateList.size();
374 }
375}
376
377void MapRemotePairwiseCalcScore(
378 double scoreStDev,

Callers

nothing calls this directly

Calls 13

GetScoreDistributionFunction · 0.85
RemoteMapFunction · 0.85
SetBestScoreFunction · 0.85
GetRemoteMapResultsMethod · 0.80
MapClass · 0.50
IsMasterMethod · 0.45
insertMethod · 0.45
endMethod · 0.45
beginMethod · 0.45
sizeMethod · 0.45
GenRandMethod · 0.45
ExecRangeMethod · 0.45

Tested by

no test coverage detected