| 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 |
nothing calls this directly
no test coverage detected