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

Function CalcStatsKernel

catboost/private/libs/algo/scoring.cpp:252–312  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

250
251
252inline static void CalcStatsKernel(
253 bool isCaching,
254 const TCalcScoreFold& fold,
255 bool isPlainMode,
256 const TStatsIndexer& indexer,
257 int depth,
258 const TCalcScoreFold::TBodyTail& bt,
259 int dim,
260 NCB::TIndexRange<int> docIndexRange,
261 TBucketStats* stats
262) {
263 Y_ASSERT(!isCaching || depth > 0);
264 if (isCaching) {
265 Fill(
266 stats + indexer.CalcSize(depth - 1),
267 stats + indexer.CalcSize(depth),
268 TBucketStats{0, 0, 0, 0}
269 );
270 } else {
271 Fill(stats, stats + indexer.CalcSize(depth), TBucketStats{0, 0, 0, 0});
272 }
273
274 if (bt.TailFinish > docIndexRange.Begin) {
275 const bool hasPairwiseWeights = !bt.PairwiseWeights.empty();
276 const float* weightsData = hasPairwiseWeights ?
277 GetDataPtr(bt.PairwiseWeights) : GetDataPtr(fold.LearnWeights);
278 const float* sampleWeightsData = hasPairwiseWeights ?
279 GetDataPtr(bt.SamplePairwiseWeights) : GetDataPtr(fold.SampleWeights);
280
281 int tailFinishInRange = Min((int)bt.TailFinish, docIndexRange.End);
282
283 if (isPlainMode) {
284 UpdateWeighted(
285 indexer,
286 GetDataPtr(bt.SampleWeightedDerivatives[dim]),
287 sampleWeightsData,
288 NCB::TIndexRange<int>(docIndexRange.Begin, tailFinishInRange),
289 stats
290 );
291 } else {
292 if (bt.BodyFinish > docIndexRange.Begin) {
293 UpdateDeltaCount(
294 indexer,
295 GetDataPtr(bt.WeightedDerivatives[dim]),
296 weightsData,
297 NCB::TIndexRange<int>(docIndexRange.Begin, Min((int)bt.BodyFinish, docIndexRange.End)),
298 stats
299 );
300 }
301 if (tailFinishInRange > bt.BodyFinish) {
302 UpdateWeighted(
303 indexer,
304 GetDataPtr(bt.SampleWeightedDerivatives[dim]),
305 sampleWeightsData,
306 NCB::TIndexRange<int>(Max((int)bt.BodyFinish, docIndexRange.Begin), tailFinishInRange),
307 stats
308 );
309 }

Callers 1

CalcStatsPointwiseFunction · 0.70

Calls 8

GetDataPtrFunction · 0.85
UpdateDeltaCountFunction · 0.85
CalcSizeMethod · 0.80
UpdateWeightedFunction · 0.70
FillFunction · 0.50
MinFunction · 0.50
MaxFunction · 0.50
emptyMethod · 0.45

Tested by

no test coverage detected