Skip to content

[BUG] Use check_y output in continuous anomaly detection metrics - #3887

Merged
TonyBagnall merged 1 commit into
aeon-toolkit:mainfrom
anshuman83-40:fix-continuous-metrics-rebind
Oct 12, 2026
Merged

TonyBagnall merged 1 commit into
aeon-toolkit:mainfrom
anshuman83-40:fix-continuous-metrics-rebind

Conversation

@anshuman83-40

Copy link
Copy Markdown
Contributor

Reference Issues/PRs

Fixes #3880

What does this implement/fix? Explain your changes.

check_y swaps y_true/y_score when their dtypes indicate they were passed the wrong way round (float labels, int scores), but the ten continuous metrics bound its result to (y_true, y_pred) and kept using the original y_score, which on the swapped path is the label array. The metrics then scored the labels against themselves, e.g. ROC AUC of 1.0 for random or inverted scores.

All ten call sites (_continuous.py and _vus_metrics.py) now rebind y_true, y_score. The y_pred name was not read before being reassigned in any of these functions, so there is no other behaviour change.

Added test_continuous_metric_swapped_arguments, parametrised over continuous_metrics: for a good and an inverted score, a swapped call warns ("permuted") and returns the same value as the correct-order call. The new test fails for all 9 metrics without the fix; test_ad_metrics.py passes (55 tests) with it, and ruff check / ruff format --check are clean.

Does your contribution introduce a new dependency? If yes, which one?

No.

Any other comments?

This pull request includes code written with the assistance of AI.
The code has not yet been reviewed by a human.

PR checklist

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.

check_y swaps the arguments when y_true is float and y_score is int, but
the callers bound the result to (y_true, y_pred) and kept scoring the
original y_score, so swapped calls scored the labels against themselves.

Fixes aeon-toolkit#3880
@aeon-actions-bot aeon-actions-bot Bot added benchmarking Benchmarking package bug Something isn't working labels Oct 3, 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: bug.
I have added the following labels to this PR based on the changes made: benchmarking. 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 TonyBagnall 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.

thanks, lgtm

@TonyBagnall
TonyBagnall merged commit 3915bff into aeon-toolkit:main Oct 12, 2026
23 of 25 checks passed
@anshuman83-40

Copy link
Copy Markdown
Contributor Author

Thanks for the review and merge!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

benchmarking Benchmarking package bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Continuous anomaly-detection metrics discard check_y's output, so swapped arguments score the labels against themselves and any detector gets 1.0

2 participants