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

Function InitPermutationData

catboost/private/libs/algo/fold.cpp:43–96  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

41}
42
43static void InitPermutationData(
44 const NCB::TTrainingDataProvider& learnData,
45 bool shuffle,
46 ui32 permuteBlockSize,
47 TRestorableFastRng64* rand,
48 TFold* fold
49) {
50 const ui32 learnSampleCount = learnData.GetObjectCount();
51 const auto& featuresArraySubsetIndexing = learnData.ObjectsData->GetFeaturesArraySubsetIndexing();
52
53 TMaybe<ui32> consecutiveSubsetBegin = featuresArraySubsetIndexing.GetConsecutiveSubsetBegin();
54 if (shuffle) {
55 if (consecutiveSubsetBegin) {
56 fold->PermutationBlockSize = learnData.ObjectsGrouping->IsTrivial() ? permuteBlockSize : 1;
57 fold->FeaturesSubsetBegin = *consecutiveSubsetBegin;
58 } else {
59 fold->PermutationBlockSize = 1;
60 }
61 fold->LearnPermutation = Shuffle(learnData.ObjectsGrouping, fold->PermutationBlockSize, rand);
62 fold->LearnPermutationFeaturesSubset = Compose(
63 featuresArraySubsetIndexing,
64 fold->LearnPermutation->GetObjectsIndexing()
65 );
66 } else {
67 if (consecutiveSubsetBegin) {
68 fold->PermutationBlockSize = learnSampleCount;
69 fold->FeaturesSubsetBegin = *consecutiveSubsetBegin;
70 } else {
71 fold->PermutationBlockSize = 1;
72 }
73
74 // implementation requires permutation vectors to exist even if they are not shuffled
75 TIndexedSubset<ui32> learnPermutation;
76 learnPermutation.yresize(learnSampleCount);
77 std::iota(learnPermutation.begin(), learnPermutation.end(), 0);
78
79 fold->LearnPermutation = TObjectsGroupingSubset(
80 learnData.ObjectsGrouping,
81 TArraySubsetIndexing<ui32>(TFullSubset<ui32>(learnData.ObjectsGrouping->GetGroupCount())),
82 EObjectsOrder::Ordered,
83 MakeMaybe<TFeaturesArraySubsetIndexing>(std::move(learnPermutation)),
84 EObjectsOrder::Ordered
85 );
86
87 TIndexedSubset<ui32> learnPermutationFeaturesSubset;
88 learnPermutationFeaturesSubset.yresize(learnSampleCount);
89 featuresArraySubsetIndexing.ForEach(
90 [&] (ui32 idx, ui32 srcIdx) { learnPermutationFeaturesSubset[idx] = srcIdx; }
91 );
92 fold->LearnPermutationFeaturesSubset = TFeaturesArraySubsetIndexing(
93 std::move(learnPermutationFeaturesSubset)
94 );
95 }
96}
97
98
99TFold TFold::BuildDynamicFold(

Callers 2

BuildDynamicFoldMethod · 0.85
BuildPlainFoldMethod · 0.85

Calls 12

ComposeFunction · 0.85
yresizeMethod · 0.80
GetGroupCountMethod · 0.80
ShuffleFunction · 0.50
moveFunction · 0.50
GetObjectCountMethod · 0.45
IsTrivialMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
ForEachMethod · 0.45

Tested by

no test coverage detected