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

Method FindBinAndPartion

library/cpp/expression/histogram_points_and_bins.cpp:30–41  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

28}
29
30const std::pair<size_t, double> THistogramPointsAndBins::FindBinAndPartion(const double& percentile) const {
31 double targetSum = std::accumulate(Bins.begin(), Bins.end(), 0.0) * percentile / 100;
32 double currentSum = 0.0;
33
34 for (size_t i = 0; i < Bins.size(); ++i) {
35 currentSum += Bins[i];
36 if (currentSum >= targetSum) {
37 return {i, 1.0 - (currentSum - targetSum) / Bins[i]};
38 }
39 }
40 return {Bins.size() - 1, 1.0};
41}
42
43bool THistogramPointsAndBins::IsEqual(const THistogramPointsAndBins& secondOperand, const double eps) const {
44 if (Points.size() != secondOperand.GetPoints().size() || Bins.size() != secondOperand.GetBins().size()) {

Callers 2

HistogramPercentileMethod · 0.80
Y_UNIT_TESTFunction · 0.80

Calls 4

accumulateFunction · 0.50
beginMethod · 0.45
endMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected