[MRG] Fix ValueDifferenceMetric feature validation - #1199
Open
aswanth-07 wants to merge 1 commit into
Open
Conversation
aswanth-07
marked this pull request as ready for review
August 9, 2026 16:41
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.
Reference Issue
Fixes #1198
What does this implement/fix? Explain your changes.
ValueDifferenceMetric.pairwisepreviously validatedXandYwith standalonecheck_arraycalls. Those checks did not compare the inputs with the fittedn_features_in_, while the distance loop processed only the fitted number of columns. As a result, extra features were silently ignored and an incomplete but plausible distance matrix was returned.This change uses fitted-estimator validation with
reset=Falsefor bothXandY. It preserves the existing non-negative andint32validation while enforcing the fitted feature count and feature-name schema.A parameterized regression test covers mismatched features in either input, and the v0.15 changelog records the fix.
Any other comments?
Validation performed locally on Windows with Python 3.10.11, NumPy 2.2.6, SciPy 1.15.3, and scikit-learn 1.7.2:
python -m pytest imblearn/metrics/tests/test_pairwise.py -q— 134 passed in 0.69spython -m pytest imblearn/metrics -q— 209 passed in 1.24sruff check imblearn/metrics/pairwise.py imblearn/metrics/tests/test_pairwise.py— passedblack --check imblearn/metrics/pairwise.py imblearn/metrics/tests/test_pairwise.py— passedgit diff --check— passedThe full
python -m pytest imblearn -qsuite was also attempted with a bounded 240-second local timeout. It did not complete within that bound and produced no captured test failure, so it is not reported as passing.#1188 is a non-overlapping maintenance PR in the same source file that replaces a deprecated SciPy distance helper; it does not address fitted feature validation.
OpenAI Codex was used to audit and de-duplicate the issue, prepare the fix, regression test, and changelog entry, run validation, and draft this pull request description.