Skip to content

[ENH] Add configurable scaling parameters and axis selection to collection rescalers - #3908

Open
melpiro wants to merge 6 commits into
mainfrom
mp/scaler-axis
Open

melpiro wants to merge 6 commits into
mainfrom
mp/scaler-axis

Conversation

@melpiro

@melpiro melpiro commented Oct 14, 2026 •

Copy link
Copy Markdown
Collaborator

Reference Issues/PRs

Fixes #3907

What does this implement/fix? Explain your changes.

This PR extends Normalizer, MinMaxScaler, and Centerer parameters.
It adds an axis parameter allowing to define the index of the time axis in the input serie/collection.
Changing the axis can, for example, be useful for preprocessing datasets for forecasting tasks.

  • Normalizer: adds mean, std, and axis.
  • MinMaxScaler: adds axis, retaining min and max.
  • Centerer: adds mean and axis.

Default parameters preserve existing behavior. For NumPy arrays,
axis determines how statistics are computed. Unequal-length
series retain per-series normalization along the time axis.

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

No.

Any other comments?

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.
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.

@aeon-actions-bot aeon-actions-bot Bot added enhancement New feature, improvement request or other non-bug code enhancement transformations Transformations package labels Oct 14, 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: enhancement.
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

@melpiro melpiro self-assigned this Oct 14, 2026
@melpiro
melpiro requested review from hadifawaz1999 and a balanced review from Copilot October 14, 2026 14:54

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Comment on lines +24 to +25
When working with unequal length series, Normalizer is only able to
use list of 2D arrays with shape (n_channels, n_timepoints_i).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is in the incorrect space it looks like. Should be above the parameters or in notes. Take a look at the numpydoc specification.

Comment on lines +47 to +51
def __init__(self, mean: float = 0.0, std: float = 1.0, axis: int = -1):
super().__init__()
self.mean = mean
self.std = std
self.axis = axis

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Can we put the parameter setting before the init.

  2. is the axis parameter ever used for the list input? I think we need some tests for different datatypes with axis if we are going to include it. The general testing will only catch issues with -1.


_tags = {
"X_inner_type": ["numpy3D", "np-list"],
"X_inner_type": ["numpy2D", "numpy3D", "np-list"],

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will make it so that the output can also be 2d, which is probably not a bad thing, but could be handled differently as well.

Any rationale for handling both 2d and 3d internally?

Comment on lines +20 to +22
axis: int, default=-1
Axis along which to compute the mean and standard deviation. Default is -1,
which corresponds to the last axis (timepoints axis).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is 0 a valid value for this? i would then normalise by case with out datatypes, not sure if that is something you ever want to do.

@melpiro

melpiro commented Nov 3, 2026 •

Copy link
Copy Markdown
Collaborator Author

Hello, Thanks for the review.

Considering your remarks, here is my updated code. I hope it is clearer and helps answer your questions.

is the axis parameter ever used for the list input?

It was not; the new commit, now allows it.

Can we put the parameter setting before the init.

I'm still relatively new to aeon, so could you explain the reasoning behind this convention? I would normally call super().init() first, then initialize the parameters. I'm wondering whether assigning them before the parent initialization could cause issues, particularly when overriding or extending default parameter values in child classes.

This will make it so that the output can also be 2d, which is probably not a bad thing, but could be handled differently as well.

Any rationale for handling both 2d and 3d internally?

While running an experiment for another PR, implementing a Transformer model in the forecasting module, I needed scalers for 2D arrays with a configurable axis parameter. (As deep learning models in forecasting use 2D arrays that can be either (channel, time) or (time, channel))

I understand that 2D arrays of shape (channel, time) and (time, channel) are not collections, but duplicating the code of collection scalers to have a new separated 'series' version of thoses scalers feels like a bad practice to me. Do you have any ideas to implement this better ?

is 0 a valid value for this? i would then normalise by case with out datatypes, not sure if that is something you ever want to do.

Yes, 0 is a valid value, especially for 2D arrays, shaped (time, channel).
Now, the code could also work on a 3D array with axis=0. Its shape would be something like (time, channel, case) but I did not add these cases 'publicly' in the docstring, as they are weird.

@melpiro
melpiro requested a review from patrickzib as a code owner November 4, 2026 13:17

This branch has not been deployed

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

Labels

enhancement New feature, improvement request or other non-bug code enhancement transformations Transformations package

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[ENH] Add configurable scaling parameters and axis selection to collection rescalers

3 participants