Skip to content

Commit

Permalink
fix bug that was dropping the last category from nominals
Browse files Browse the repository at this point in the history
  • Loading branch information
paulbkoch committed Jan 6, 2025
1 parent 15a600d commit e0bcadd
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
15 changes: 8 additions & 7 deletions shared/libebm/PartitionOneDimensionalBoosting.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1175,14 +1175,15 @@ template<bool bHessian, size_t cCompilerScores> class PartitionOneDimensionalBoo
auto** const ppBinShuffleEnd = apBins + cKeep;
do {
EBM_ASSERT(1 <= cRemaining);
if(1 == cRemaining) {
break; // it will always be zero
if(1 != cRemaining) {
const size_t iSwap = pRng->NextFast(cRemaining);
auto* const pTemp = ppBinShuffle[iSwap];
--cRemaining;
ppBinShuffle[iSwap] = *ppBinShuffle;
*ppBinShuffle = pTemp;
} else {
EBM_ASSERT(ppBinShuffleEnd == ppBinShuffle + 1);
}
const size_t iSwap = pRng->NextFast(cRemaining);
auto* const pTemp = ppBinShuffle[iSwap];
--cRemaining;
ppBinShuffle[iSwap] = *ppBinShuffle;
*ppBinShuffle = pTemp;
++ppBinShuffle;
} while(ppBinShuffleEnd != ppBinShuffle);

Expand Down
2 changes: 1 addition & 1 deletion shared/libebm/tests/boosting_unusual_inputs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2367,7 +2367,7 @@ static double RandomizedTesting(const AccelerationFlags acceleration) {
}

TEST_CASE("stress test, boosting") {
const double expected = 12286777380857.959;
const double expected = 12298977636064.098;

double validationMetricExact = RandomizedTesting(AccelerationFlags_NONE);
CHECK(validationMetricExact == expected);
Expand Down

0 comments on commit e0bcadd

Please sign in to comment.