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

Function MapGetApprox

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

Source from the content-addressed store, hash-verified

904
905
906void MapGetApprox(
907 const NCB::TTrainingDataProviders& data,
908 const TLearnContext& ctx,
909 bool useBestModel,
910 TVector<TVector<double>>* learnApprox, // [dim][docIdx], can be nullptr
911 TVector<TVector<TVector<double>>>* testApprox) { // [test][dim][docIdx], can be nullptr
912
913 Y_ASSERT(ctx.Params.SystemOptions->IsMaster());
914
915 const TVector<TApproxesResult> resultsFromWorkers = ApplyMapper<TApproxGetter>(
916 TMasterEnvironment::GetRef().RootEnvironment->GetSlaveCount(),
917 TMasterEnvironment::GetRef().SharedTrainData,
918 TApproxGetterParams{
919 learnApprox != nullptr,
920 testApprox != nullptr,
921 /*ReturnBestTestApprox*/ useBestModel
922 }
923 );
924
925 auto approxDimension = ctx.LearnProgress->ApproxDimension;
926
927 if (learnApprox) {
928 MergeApproxesFromWorkers(
929 resultsFromWorkers,
930 approxDimension,
931 data.Learn->GetObjectCount(),
932 /*getApproxPart*/ [&] (const TApproxesResult& resultFromWorker) -> const TVector<TVector<double>>& {
933 return resultFromWorker.LearnApprox;
934 },
935 learnApprox
936 );
937 }
938
939 if (testApprox) {
940 auto testCount = data.Test.size();
941
942 testApprox->resize(testCount);
943 for (auto testIdx : xrange(testCount)) {
944 const bool assignFromBestApprox = useBestModel && (testIdx == 0);
945
946 MergeApproxesFromWorkers(
947 resultsFromWorkers,
948 approxDimension,
949 data.Test[testIdx]->GetObjectCount(),
950 /*getApproxPart*/ [&] (const TApproxesResult& resultFromWorker) -> const TVector<TVector<double>>& {
951 return assignFromBestApprox ?
952 resultFromWorker.BestTestApprox :
953 resultFromWorker.TestApprox[testIdx];
954 },
955 &(*testApprox)[testIdx]
956 );
957 }
958 }
959}

Callers 2

CalcErrorsDistributedFunction · 0.85
TrainFunction · 0.85

Calls 7

MergeApproxesFromWorkersFunction · 0.85
xrangeFunction · 0.85
IsMasterMethod · 0.45
GetSlaveCountMethod · 0.45
GetObjectCountMethod · 0.45
sizeMethod · 0.45
resizeMethod · 0.45

Tested by

no test coverage detected