Skip to content

[MRG] Fix ValueDifferenceMetric feature validation - #1199

Open
aswanth-07 wants to merge 1 commit into
scikit-learn-contrib:masterfrom
aswanth-07:agent/fix-vdm-feature-validation
Open

[MRG] Fix ValueDifferenceMetric feature validation#1199
aswanth-07 wants to merge 1 commit into
scikit-learn-contrib:masterfrom
aswanth-07:agent/fix-vdm-feature-validation

Conversation

@aswanth-07

Copy link
Copy Markdown

Reference Issue

Fixes #1198

What does this implement/fix? Explain your changes.

ValueDifferenceMetric.pairwise previously validated X and Y with standalone check_array calls. Those checks did not compare the inputs with the fitted n_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=False for both X and Y. It preserves the existing non-negative and int32 validation 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.69s
  • python -m pytest imblearn/metrics -q — 209 passed in 1.24s
  • ruff check imblearn/metrics/pairwise.py imblearn/metrics/tests/test_pairwise.py — passed
  • black --check imblearn/metrics/pairwise.py imblearn/metrics/tests/test_pairwise.py — passed
  • git diff --check — passed

The full python -m pytest imblearn -q suite 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.

@aswanth-07
aswanth-07 marked this pull request as ready for review August 9, 2026 16:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] ValueDifferenceMetric.pairwise silently ignores extra features

1 participant