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

Function BestWeightedSplitImpl

library/cpp/grid_creator/binarization.cpp:1523–1553  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1521
1522 template<EPenaltyType penaltyType, class TWeightIteratorType>
1523 THashSet<float> BestWeightedSplitImpl(
1524 TVector<float>&& featureValues,
1525 TWeightIteratorType weightsIterator,
1526 int maxBordersCount,
1527 EOptimizationType optimizationType,
1528 bool filterNans,
1529 bool featuresAreSorted,
1530 bool normalizeWeights = true
1531 ) {
1532 auto[uniqueFeatureValues, uniqueValueWeights] = GroupAndSortWeighedValuesImpl(
1533 std::move(featureValues),
1534 weightsIterator,
1535 filterNans,
1536 featuresAreSorted,
1537 normalizeWeights,
1538 /*cumulativeWeights*/ optimizationType == EOptimizationType::Greedy);
1539 if (uniqueFeatureValues.empty()) {
1540 return {};
1541 }
1542 switch (optimizationType) {
1543 case EOptimizationType::Exact:
1544 return BestSplit<penaltyType>(uniqueFeatureValues, uniqueValueWeights, /*initialBorders=*/Nothing(), maxBordersCount);
1545 case EOptimizationType::Greedy: {
1546 TWeightedFeatureBin<float, penaltyType> initialBin(
1547 0, uniqueFeatureValues.size(), uniqueFeatureValues.begin(), uniqueValueWeights.begin());
1548 return GreedySplit(initialBin, /*initialBorders=*/Nothing(), maxBordersCount);
1549 }
1550 default:
1551 throw (yexception() << "Invalid Optimization type.");
1552 }
1553 }
1554}
1555
1556

Callers

nothing calls this directly

Calls 8

NothingFunction · 0.85
GreedySplitFunction · 0.85
yexceptionClass · 0.85
moveFunction · 0.50
emptyMethod · 0.45
sizeMethod · 0.45
beginMethod · 0.45

Tested by

no test coverage detected