Skip to content

Preserve string and integer class labels in ClassHistogram - #697

Open
AryanRG wants to merge 4 commits into
interpretml:mainfrom
AryanRG:fix-class-histogram-labels
Open

AryanRG wants to merge 4 commits into
interpretml:mainfrom
AryanRG:fix-class-histogram-labels

Conversation

@AryanRG

@AryanRG AryanRG commented Oct 22, 2026 •

Copy link
Copy Markdown

ClassHistogram tries to cast all targets to float before computing class counts. This merges numeric-looking string labels such as "01" and "1", and loses precision for large integer labels.

Preserve string class names and integer values while retaining numeric float grouping, including signed zero and numeric ordering. Serialize integer chart labels as strings after numeric sorting. Added regression tests for these cases and unsigned labels.

Histogram and adjacent visualization tests and formatting pass. Existing lint and type-check diagnostics are unchanged.

@codecov

codecov Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 75.00000% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 68.08%. Comparing base (4a492be) to head (5a1ab3e).

Files with missing lines Patch % Lines
python/interpret-core/interpret/data/_response.py 75.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #697      +/-   ##
==========================================
+ Coverage   67.80%   68.08%   +0.28%     
==========================================
  Files          77       77              
  Lines       11893    11898       +5     
==========================================
+ Hits         8064     8101      +37     
+ Misses       3829     3797      -32     
Flag Coverage Δ
bdist_linux_311_python 67.86% <75.00%> (+0.31%) ⬆️
bdist_linux_312_python ?
bdist_linux_313_python ?
bdist_linux_314_python 67.77% <75.00%> (+0.33%) ⬆️
bdist_linuxarm_311_python 67.87% <75.00%> (+0.31%) ⬆️
bdist_linuxarm_312_python ?
bdist_linuxarm_313_python ?
bdist_linuxarm_314_python 67.77% <75.00%> (+0.30%) ⬆️
bdist_mac_311_python 68.00% <75.00%> (+0.31%) ⬆️
bdist_mac_312_python ?
bdist_mac_313_python ?
bdist_mac_314_python 67.93% <75.00%> (+0.33%) ⬆️
bdist_win_311_python 68.01% <75.00%> (+0.29%) ⬆️
bdist_win_312_python ?
bdist_win_313_python ?
bdist_win_314_python 67.93% <75.00%> (+0.31%) ⬆️
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.

Signed-off-by: AryanRG <aryanrganjoo@gmail.com>
@AryanRG
AryanRG force-pushed the fix-class-histogram-labels branch from 8779f3c to 90e8cda Compare October 23, 2026 05:33

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Large integer labels still lose precision in browser-rendered overall histograms and collapse into the same category.

1 open issue
What changed in this PR

This PR updates ClassHistogram target handling to preserve distinct string labels and exact integer values while retaining numeric float grouping and ordering.

Changes:

  • Avoids float conversion for integer and string targets.
  • Adds regression tests for label preservation, class counts, unsigned integers, and float semantics across multiple input containers.
File Description
python/​interpret-core/​tests/​data/​test_class_histogram.py Adds label-preservation and histogram regression tests.
python/​interpret-core/​interpret/​data/​_response.py Selects target conversion based on label types.

Review effort: Balanced

Comment thread python/interpret-core/interpret/data/_response.py

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.

3 participants