Skip to content

Commit e0bcadd

Browse files
committed
fix bug that was dropping the last category from nominals
1 parent 15a600d commit e0bcadd

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

shared/libebm/PartitionOneDimensionalBoosting.cpp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1175,14 +1175,15 @@ template<bool bHessian, size_t cCompilerScores> class PartitionOneDimensionalBoo
11751175
auto** const ppBinShuffleEnd = apBins + cKeep;
11761176
do {
11771177
EBM_ASSERT(1 <= cRemaining);
1178-
if(1 == cRemaining) {
1179-
break; // it will always be zero
1178+
if(1 != cRemaining) {
1179+
const size_t iSwap = pRng->NextFast(cRemaining);
1180+
auto* const pTemp = ppBinShuffle[iSwap];
1181+
--cRemaining;
1182+
ppBinShuffle[iSwap] = *ppBinShuffle;
1183+
*ppBinShuffle = pTemp;
1184+
} else {
1185+
EBM_ASSERT(ppBinShuffleEnd == ppBinShuffle + 1);
11801186
}
1181-
const size_t iSwap = pRng->NextFast(cRemaining);
1182-
auto* const pTemp = ppBinShuffle[iSwap];
1183-
--cRemaining;
1184-
ppBinShuffle[iSwap] = *ppBinShuffle;
1185-
*ppBinShuffle = pTemp;
11861187
++ppBinShuffle;
11871188
} while(ppBinShuffleEnd != ppBinShuffle);
11881189

shared/libebm/tests/boosting_unusual_inputs.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2367,7 +2367,7 @@ static double RandomizedTesting(const AccelerationFlags acceleration) {
23672367
}
23682368

23692369
TEST_CASE("stress test, boosting") {
2370-
const double expected = 12286777380857.959;
2370+
const double expected = 12298977636064.098;
23712371

23722372
double validationMetricExact = RandomizedTesting(AccelerationFlags_NONE);
23732373
CHECK(validationMetricExact == expected);

0 commit comments

Comments
 (0)