| 97 | |
| 98 | |
| 99 | TFold TFold::BuildDynamicFold( |
| 100 | const NCB::TTrainingDataProviders& data, |
| 101 | const TVector<TTargetClassifier>& targetClassifiers, |
| 102 | bool shuffle, |
| 103 | ui32 permuteBlockSize, |
| 104 | int approxDimension, |
| 105 | double multiplier, |
| 106 | bool storeExpApproxes, |
| 107 | bool hasPairwiseWeights, |
| 108 | const TMaybe<TVector<double>>& startingApprox, |
| 109 | const NCatboostOptions::TBinarizationOptions& onlineEstimatedFeaturesQuantizationOptions, |
| 110 | TQuantizedFeaturesInfoPtr onlineEstimatedFeaturesQuantizedInfo, |
| 111 | TRestorableFastRng64* rand, |
| 112 | NPar::ILocalExecutor* localExecutor |
| 113 | ) { |
| 114 | const NCB::TTrainingDataProvider& learnData = *data.Learn; |
| 115 | |
| 116 | const ui32 learnSampleCount = learnData.GetObjectCount(); |
| 117 | |
| 118 | TFold ff; |
| 119 | ff.SampleWeights.resize(learnSampleCount, 1); |
| 120 | |
| 121 | InitPermutationData(learnData, shuffle, permuteBlockSize, rand, &ff); |
| 122 | |
| 123 | ff.AssignTarget(learnData.TargetData->GetTarget(), targetClassifiers, localExecutor); |
| 124 | ff.SetWeights(GetWeights(*learnData.TargetData), learnSampleCount); |
| 125 | |
| 126 | TVector<ui32> queryIndices; |
| 127 | |
| 128 | auto maybeGroupInfos = learnData.TargetData->GetGroupInfo(); |
| 129 | if (maybeGroupInfos) { |
| 130 | if (shuffle) { |
| 131 | GetGroupInfosSubset(*maybeGroupInfos, *ff.LearnPermutation, localExecutor, &ff.LearnQueriesInfo); |
| 132 | } else { |
| 133 | ff.LearnQueriesInfo.insert( |
| 134 | ff.LearnQueriesInfo.end(), |
| 135 | maybeGroupInfos->begin(), |
| 136 | maybeGroupInfos->end() |
| 137 | ); |
| 138 | } |
| 139 | queryIndices = GetQueryIndicesForDocs(ff.LearnQueriesInfo, learnSampleCount); |
| 140 | } |
| 141 | |
| 142 | TVector<float> pairwiseWeights; |
| 143 | if (hasPairwiseWeights) { |
| 144 | pairwiseWeights.resize(learnSampleCount); |
| 145 | CalcPairwiseWeights(ff.LearnQueriesInfo, ff.LearnQueriesInfo.ysize(), &pairwiseWeights); |
| 146 | } |
| 147 | |
| 148 | TMaybeData<TConstArrayRef<TConstArrayRef<float>>> baseline = learnData.TargetData->GetBaseline(); |
| 149 | |
| 150 | ui32 leftPartLen = UpdateSize( |
| 151 | SelectMinBatchSize(learnSampleCount), |
| 152 | ff.LearnQueriesInfo, |
| 153 | queryIndices, |
| 154 | learnSampleCount |
| 155 | ); |
| 156 | while (ff.BodyTailArr.empty() || leftPartLen < learnSampleCount) { |
nothing calls this directly
no test coverage detected