Skip to content

Preserve numeric labels when adapting single-class classifiers - #680

Open
Linxiushen wants to merge 1 commit into
interpretml:mainfrom
Linxiushen:fix/preserve-single-class-labels
Open

Linxiushen wants to merge 1 commit into
interpretml:mainfrom
Linxiushen:fix/preserve-single-class-labels

Conversation

@Linxiushen

@Linxiushen Linxiushen commented Sep 27, 2026 •

Copy link
Copy Markdown

The single-class adapter adds a synthetic string class using NumPy's inferred dtype. For integer or boolean classes, this also converts the original label to a string. PR(model).explain_perf(X, y) and ROC(model).explain_perf(X, y) then raise KeyError while looking up the original labels; explanation records can instead mark the observed class as unknown with probability zero.

Preserve the original label in an object array alongside the synthetic class. The regression tests fit real sklearn classifiers and cover public PR/ROC calls, explanation label/probability mapping, single-sample inputs, strings, and the ordinary binary path.

Validation on Windows / Python 3.12:

  • New regressions: 12 failed / 9 passed before the fix.
  • New tests plus related cleaning/explanation tests: 26 passed / 1 skipped after the fix.
  • All applicable configured pre-commit hooks pass.
  • Advisory mypy is blocked by NumPy 2.5 stubs using Python 3.12 syntax with the repository's Python 3.10 target; identical failure reproduced on unchanged main.

Single-class ROC metrics remain undefined as reported by sklearn. Full EBM/native and browser suites were not run.

Hosted CI follow-up: all 21 new regression cases pass in both failed Python jobs. Their APLR MRO errors also occur in a scheduled run on the same unchanged base; Powerlift's SQLAlchemy 2.1.1 / sqlalchemy-utils 0.42.1 import failure likewise reproduces there. Docs additionally fails when the fork token tries to create its warning check (403). The workflow has 30 successful, 4 failed and 31 cancelled jobs, so the full matrix remains incomplete. DCO is a separate owner-attestation gate. Same-base comparison run.

@codecov

codecov Bot commented Sep 27, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 22.78%. Comparing base (560f8dd) to head (a36fe00).

❗ There is a different number of reports uploaded between BASE (560f8dd) and HEAD (a36fe00). Click for more details.

HEAD has 776 uploads less than BASE
Flag BASE (560f8dd) HEAD (a36fe00)
sdist_linuxarm_311_python 43 1
sdist_linuxarm_313_python 43 1
sdist_linuxarm_314_python 43 1
sdist_linuxarm_312_python 43 1
sdist_mac_314_python 38 1
sdist_mac_311_python 11 0
sdist_mac_313_python 42 1
sdist_mac_312_python 37 1
sdist_linux_312_python 42 0
sdist_linux_314_python 39 1
sdist_linux_313_python 42 1
sdist_linux_311_python 43 1
bdist_mac_313_python 16 0
sdist_win_314_python 7 0
bdist_mac_311_python 8 0
bdist_linuxarm_314_python 30 1
sdist_win_313_python 7 0
bdist_linuxarm_311_python 29 1
sdist_win_311_python 7 0
bdist_linuxarm_313_python 32 1
bdist_mac_312_python 19 1
bdist_mac_314_python 21 0
bdist_win_311_python 10 0
bdist_linuxarm_312_python 33 0
bdist_linux_311_python 20 0
bdist_linux_314_python 17 1
sdist_win_312_python 7 0
bdist_linux_313_python 18 0
bdist_linux_312_python 20 0
bdist_win_314_python 8 0
bdist_win_313_python 10 0
bdist_win_312_python 6 0
Additional details and impacted files
@@             Coverage Diff             @@
##             main     #680       +/-   ##
===========================================
- Coverage   67.21%   22.78%   -44.44%     
===========================================
  Files          77       77               
  Lines       11735    11735               
===========================================
- Hits         7888     2674     -5214     
- Misses       3847     9061     +5214     
Flag Coverage Δ
bdist_linux_311_python ?
bdist_linux_312_python ?
bdist_linux_313_python ?
bdist_linux_314_python 22.51% <100.00%> (-44.37%) ⬇️
bdist_linuxarm_311_python 21.65% <100.00%> (-45.34%) ⬇️
bdist_linuxarm_312_python ?
bdist_linuxarm_313_python 21.65% <100.00%> (-45.34%) ⬇️
bdist_linuxarm_314_python 22.52% <100.00%> (-44.37%) ⬇️
bdist_mac_311_python ?
bdist_mac_312_python 20.86% <100.00%> (-46.27%) ⬇️
bdist_mac_313_python ?
bdist_mac_314_python ?
bdist_win_311_python ?
bdist_win_312_python ?
bdist_win_313_python ?
bdist_win_314_python ?
sdist_linux_311_python 18.38% <100.00%> (-48.54%) ⬇️
sdist_linux_312_python ?
sdist_linux_313_python 18.38% <100.00%> (-48.54%) ⬇️
sdist_linux_314_python 18.17% <100.00%> (-48.66%) ⬇️
sdist_linuxarm_311_python 16.79% <100.00%> (-50.14%) ⬇️
sdist_linuxarm_312_python 22.66% <100.00%> (-44.27%) ⬇️
sdist_linuxarm_313_python 22.66% <100.00%> (-44.27%) ⬇️
sdist_linuxarm_314_python 20.46% <100.00%> (-46.37%) ⬇️
sdist_mac_311_python ?
sdist_mac_312_python 12.38% <0.00%> (-54.67%) ⬇️
sdist_mac_313_python 22.62% <100.00%> (-44.43%) ⬇️
sdist_mac_314_python 20.57% <100.00%> (-46.38%) ⬇️
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.

This branch has not been deployed

No deployments
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.

1 participant