Skip to content

[BUG] Warn instead of error on numeric binary regression targets - #3768

Open
alexbanwell1 wants to merge 2 commits into
aeon-toolkit:mainfrom
alexbanwell1:allow-binary-regression-target
Open

[BUG] Warn instead of error on numeric binary regression targets#3768
alexbanwell1 wants to merge 2 commits into
aeon-toolkit:mainfrom
alexbanwell1:allow-binary-regression-target

Conversation

@alexbanwell1

Copy link
Copy Markdown
Contributor

Reference Issues/PRs

None (spotted while running window-based forecasters on short M4 series).

What does this implement/fix? Explain your changes.

check_regression_y accepts "continuous" and "multiclass" targets but
rejects "binary" ones with a ValueError. However, a numeric target with
only one or two unique values is reported by
sklearn.utils.multiclass.type_of_target as "binary" even though it is a
perfectly valid regression target — for example a short or first-differenced
integer series whose windowed targets happen to take only a couple of distinct
values.

Because RegressionForecaster (and forecasters built on it, e.g. a differenced
regression forecaster) construct their target as a slice of a real-valued
series, they crash on such series:

ValueError: y type is binary which is not valid for regression.
Should be continuous according to sklearn.utils.multiclass.type_of_target

This is inconsistent with "multiclass" (3+ unique integer values) already being
accepted — the only thing separating the two cases is whether the target happens
to have 2 or 3 unique values.

This PR makes check_regression_y fit numeric binary/constant targets as
regression targets but emit a UserWarning
, so a genuinely mis-passed
classification target is still flagged without hard-failing on legitimate
degenerate targets. String targets are still rejected via the existing check.

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

No.

Any other comments?

  • New/updated tests in aeon/utils/validation/tests/test_labels.py:
    • multiclass integer targets accepted with no warning,
    • binary/constant numeric targets accepted with a UserWarning,
    • string targets (binary and multiclass) still raise ValueError.
  • check_regression_y local test module passes (81 passed).

PR checklist

  • The PR title starts with either [ENH], [MNT], [DOC], [BUG], [REF], [DEP] or [GOV].
  • I've added unit tests and made sure they pass locally.

check_regression_y accepted "continuous" and "multiclass" targets but
rejected "binary" ones. A numeric target with only one or two unique
values (e.g. a short or first-differenced integer series whose windowed
targets happen to take a couple of values) is reported by
sklearn's type_of_target as "binary", yet is a valid regression target.

This made window-based forecasters (RegressionForecaster and the
DifferencedForecaster built on it) crash on some short/integer series.

Numeric binary targets are now fitted as regression targets with a
UserWarning flagging that they may be a misused classification target;
string targets are still rejected via the existing check.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@aeon-actions-bot aeon-actions-bot Bot added the bug Something isn't working label Aug 29, 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 ].

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

@alexbanwell1 alexbanwell1 self-assigned this Aug 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants