Skip to content

Fix R EBM outer bag score aggregation - #677

Merged
paulbkoch merged 1 commit into
interpretml:mainfrom
TemidayoA:fix/r-ebm-outer-bag-aggregation-417
Aug 16, 2026
Merged

Fix R EBM outer bag score aggregation#677
paulbkoch merged 1 commit into
interpretml:mainfrom
TemidayoA:fix/r-ebm-outer-bag-aggregation-417

Conversation

@TemidayoA

Copy link
Copy Markdown
Contributor

Summary

  • Accumulate term scores from every outer bag before averaging them.
  • Add an R regression test for imbalanced binary classification.
  • Include the R tests directory in the package build.

Root cause

ebm_classify() overwrote term_scores during each outer-bag iteration and then divided only the final bag’s scores by outer_bags. As the bag count increased, this shrank the logits toward zero and pushed predicted probabilities toward 0.5.

The problem was therefore incorrect outer-bag aggregation, not a missing intercept.

Using the dataset from the issue, the mean predicted probability with 16 bags changed from 0.390069 to 0.100096, closely matching the observed positive rate of 0.1.

Validation

  • R CMD check --no-manual passed, with one existing installed-size note.
  • The regression test passes for the original imbalanced dataset.
  • Mean predictions remain consistent with outer_bags set to 1, 2, 4, 8, and 16.

Fixes #417

Signed-off-by: Temidayo Akindahunsi <98013820+TemidayoA@users.noreply.github.com>
@codecov

codecov Bot commented Aug 16, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 67.20%. Comparing base (2ed5ecb) to head (5273772).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #677      +/-   ##
==========================================
- Coverage   67.25%   67.20%   -0.06%     
==========================================
  Files          77       77              
  Lines       11735    11735              
==========================================
- Hits         7892     7886       -6     
- Misses       3843     3849       +6     
Flag Coverage Δ
bdist_linux_311_python 66.97% <ø> (ø)
bdist_linux_312_python 66.95% <ø> (-0.02%) ⬇️
bdist_linux_313_python 66.97% <ø> (ø)
bdist_linux_314_python 66.87% <ø> (ø)
bdist_linuxarm_311_python 66.98% <ø> (ø)
bdist_linuxarm_312_python 66.98% <ø> (ø)
bdist_linuxarm_313_python 66.98% <ø> (ø)
bdist_linuxarm_314_python 66.87% <ø> (-0.04%) ⬇️
bdist_mac_311_python 67.11% <ø> (-0.04%) ⬇️
bdist_mac_312_python 67.13% <ø> (-0.02%) ⬇️
bdist_mac_313_python 67.11% <ø> (-0.02%) ⬇️
bdist_mac_314_python 67.03% <ø> (ø)
bdist_win_311_python 67.14% <ø> (-0.04%) ⬇️
bdist_win_312_python 67.13% <ø> (-0.04%) ⬇️
bdist_win_313_python 67.13% <ø> (-0.06%) ⬇️
bdist_win_314_python 67.03% <ø> (-0.04%) ⬇️
sdist_linux_311_python ?
sdist_linux_312_python ?
sdist_linux_313_python ?
sdist_linux_314_python ?
sdist_linuxarm_311_python ?
sdist_linuxarm_312_python ?
sdist_linuxarm_313_python ?
sdist_linuxarm_314_python ?
sdist_mac_311_python ?
sdist_mac_312_python ?
sdist_mac_313_python ?
sdist_mac_314_python ?
sdist_win_311_python ?
sdist_win_312_python ?
sdist_win_313_python ?
sdist_win_314_python ?

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@TemidayoA

Copy link
Copy Markdown
Contributor Author

CI note: I investigated the three failing checks in run 31942930664. They are unrelated to this R-only change:

  • format_ruff encounters a 403: Resource not accessible by integration while its reporting step attempts to create a check-run from the fork PR.
  • docs reports execution failures across multiple documentation notebooks, followed by the same check-run permission error. This PR does not modify any documentation or Python files.
  • testS (win_314_python) cannot build interpret-core because MSBuild.exe is unavailable on the runner; the subsequent test step also reports that pytest is unavailable.

The change was validated locally with R CMD check --no-manual, the new regression test, and the original imbalanced-data reproduction across outer_bags values 1, 2, 4, 8, and 16.

Could a maintainer please rerun the affected checks or confirm whether these are known workflow issues?

@paulbkoch

Copy link
Copy Markdown
Collaborator

Thanks @TemidayoA! I agree the failing tests are unrelated to this PR. The testR CI step for the R package completed without error, so I will merge. Good find!

@paulbkoch
paulbkoch merged commit 654cbdc into interpretml:main Aug 16, 2026
50 of 68 checks passed
@TemidayoA

Copy link
Copy Markdown
Contributor Author

Thank you so much, @paulbkoch! I really appreciate you reviewing the PR, confirming the unrelated checks, and merging the fix. Glad I could help track this down, looking forward to contributing more

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

R: intercept may not be handled correctly

2 participants