Validate binary outcome in filter_LR / filter_D (#349)#941
Open
jeongyoonlee wants to merge 1 commit into
Open
Conversation
The likelihood-ratio filter (filter_LR) and the divergence-based filters (filter_D: KL / ED / Chi) model a binary conversion outcome. Passing a continuous or multi-class outcome previously produced meaningless statistics silently. Add a module-level _check_binary_outcome() helper, called at the top of filter_LR and filter_D, that raises a clear ValueError naming the offending column and pointing to filter_F for continuous outcomes. The module docstring now documents the binary-only constraint. Reimplements the work of @jbbqqf in #898 (CLA-blocked). Closes #349.
jeongyoonlee
requested review from
alexander-pv,
huigangchen,
paullo0106,
ppstacy,
ras44,
t-tte,
vincewu51 and
zhenyuz0500
July 14, 2026 17:08
2 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Proposed changes
The likelihood-ratio filter (
filter_LR) and the divergence-based filters (filter_D—KL/ED/Chi) model a binary conversion outcome. Passing a continuous or multi-class outcome previously produced meaningless statistics silently, with no error.This adds a module-level
_check_binary_outcome()helper, called at the top offilter_LRandfilter_D, that raises a clearValueErrornaming the offending outcome column and pointing tofilter_F(the OLS F-test filter, which tolerates continuous outcomes). The module docstring now documents the binary-only constraint.filter_Fis unchanged.Fixes #349.
Credit
Reimplements the work of @jbbqqf in #898, which is CLA-blocked and cannot be merged directly. Full credit to @jbbqqf for the original implementation and analysis; this PR re-lands the same feature against current
masterunder a CLA-clean author.Types of changes
Tests
test_filter_rejects_non_binary_outcomeover["LR", "KL", "ED", "Chi"](4-class outcome →ValueErrormatching "binary") andtest_filter_f_accepts_continuous_outcome(continuous outcome still works throughfilter_F). The rejects tests fail onmaster(no error raised), pass here.tests/test_feature_selection.py— 8 passed.