Skip to content

[MNT] remove imbalanced-learn test dependency and raise imbalance coverage - #3671

Open
TonyBagnall wants to merge 4 commits into
mainfrom
ajb/imbalance
Open

[MNT] remove imbalanced-learn test dependency and raise imbalance coverage#3671
TonyBagnall wants to merge 4 commits into
mainfrom
ajb/imbalance

Conversation

@TonyBagnall

Copy link
Copy Markdown
Contributor

Address part of #3654.

After #3669 I will update this to remove the soft dependency, #3669 to go in first.

The SMOTE and ADASYN tests used imbalanced-learn as a runtime parity oracle behind a soft-dependency skip. Replace the skipped equivalence tests with hardcoded reference values captured from imblearn 0.14.2 (SMOTE k_neighbors=1 / ADASYN n_neighbors=1, random_state=49); this port reproduces them bit-identically, so the whole suite now passes with imbalanced-learn uninstalled.

While we are Raise imbalance package coverage from 89% to 99% with functional tests: multi-class skip of already-balanced classes, ADASYN RuntimeError (no majority neighbours) and ValueError (rounding yields no samples), ESMOTE determinism, and OHIT single-sample-minority tiling and no-cluster fallback.

Remove genuinely dead code rather than test it: the Borderline-SMOTE-2 y-weighting branch in SMOTE._generate_samples (never called; _make_samples always passes y=None) and the return_bias branch in ESMOTE (always called with return_bias=False).

For all contributions
  • I've added myself to the list of contributors. Alternatively, you can use the @all-contributors bot to do this for you after the PR has been merged.
  • The PR title starts with either [ENH], [MNT], [DOC], [BUG], [REF], [DEP] or [GOV] indicating whether the PR topic is related to enhancement, maintenance, documentation, bugs, refactoring, deprecation or governance.
For new estimators and functions
  • I've added the estimator/function to the online API documentation.
  • (OPTIONAL) I've added myself as a __maintainer__ at the top of relevant files and want to be contacted regarding its maintenance. Unmaintained files may be removed. This is for the full file, and you should not add yourself if you are just making minor changes or do not want to help maintain its contents.
For developers with write access
  • (OPTIONAL) I've updated aeon's CODEOWNERS to receive notifications about future changes to these files.

…erage

Address part of #3654. The SMOTE and ADASYN tests used imbalanced-learn
as a runtime parity oracle behind a soft-dependency skip. Replace the
skipped equivalence tests with hardcoded reference values captured from
imblearn 0.14.2 (SMOTE k_neighbors=1 / ADASYN n_neighbors=1,
random_state=49); this port reproduces them bit-identically, so the whole
suite now passes with imbalanced-learn uninstalled.

Raise imbalance package coverage from 89% to 99% with functional tests:
multi-class skip of already-balanced classes, ADASYN RuntimeError (no
majority neighbours) and ValueError (rounding yields no samples), ESMOTE
determinism, and OHIT single-sample-minority tiling and no-cluster
fallback.

Remove genuinely dead code rather than test it: the Borderline-SMOTE-2
y-weighting branch in SMOTE._generate_samples (never called; _make_samples
always passes y=None) and the return_bias branch in ESMOTE
(always called with return_bias=False).

Remaining uncovered: OHIT noise-point/zero-density branches, reachable
only via contrived seed-fragile cluster geometries, and SMOTE
_get_test_params, covered by the global estimator conformance suite.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@aeon-actions-bot aeon-actions-bot Bot added maintenance Continuous integration, unit testing & package distribution transformations Transformations package labels Jul 23, 2026
@aeon-actions-bot

Copy link
Copy Markdown
Contributor

Thank you for contributing to aeon

I have added the following labels to this PR based on the title: [ maintenance ].
I have added the following labels to this PR based on the changes made: [ transformations ]. Feel free to change these if they do not properly represent the PR.

The Checks tab will show the status of our automated tests. You can click on individual test runs in the tab or "Details" in the panel below to see more information if there is a failure.

If our pre-commit code quality check fails, please run pre-commit locally and push the fixes to your PR branch.

Don't hesitate to ask questions on the aeon Discord channel if you have any.

PR CI actions

These checkboxes will add labels to enable or disable CI functionality for this PR. This may not take effect immediately, and a new commit may be required to run the new configuration.

  • Run pre-commit checks for all files
  • Run mypy typecheck tests
  • Run all pytest tests and configurations
  • Run all notebook example tests
  • Run numba-disabled codecov tests
  • Disable numba cache loading
  • Regenerate expected results for testing
  • Push an empty commit to re-run CI checks

TonyBagnall and others added 2 commits July 23, 2026 08:52
RedComets no longer uses imbalanced-learn (its oversampling now runs through
aeon's own SMOTE and RandomOverSampler), so drop the dependency entirely:

- remove "imbalanced-learn" from the all_extras optional dependencies in
  pyproject.toml;
- sever the two remaining test-time imblearn parity oracles. The
  RandomOverSampler imblearn-match test is replaced by a multi-class balancing
  test (its behaviour was already covered by the balance/originals/multivariate
  tests), and the RedComets SMOTE oracle test becomes an imblearn-free wiring
  test asserting the oversampling balances classes and preserves the original
  normalised cases. SMOTE's numerical parity with imblearn is locked separately
  by the hardcoded reference test in the imbalance package.

The imbalance and RedComets suites now pass with imbalanced-learn uninstalled.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@TonyBagnall
TonyBagnall requested a review from patrickzib as a code owner July 23, 2026 08:18
@MatthewMiddlehurst MatthewMiddlehurst added the codecov actions Run the codecov action on a PR label Jul 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

codecov actions Run the codecov action on a PR imbalance maintenance Continuous integration, unit testing & package distribution transformations Transformations package

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants