Repository navigation
Conversation
MultiNormalizer inherited sklearn's fit_transform, which fitted on one column per target and then transformed the same array, although transform takes one row per target for arrays and tensors, and it never passed X on. Fixes sktime#2472.
bercedev
requested review from
benHeid,
fkiraly,
jdb78 and
phoeenniixx
as code owners
October 20, 2026 22:38
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2473 +/- ##
=======================================
Coverage ? 88.82%
=======================================
Files ? 218
Lines ? 11675
Branches ? 0
=======================================
Hits ? 10370
Misses ? 1305
Partials ? 0
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Reference Issues/PRs
Fixes #2472.
What does this implement/fix? Explain your changes.
MultiNormalizerhad nofit_transformof its own, so it used sklearn'sTransformerMixin.fit_transform, i.e.self.fit(y).transform(y). That breaks in two ways:fitreads one column per target (y[:, idx]), but for ndarray and Tensor inputtransformreads one row per target (y[idx]), and only transposes a DataFrame itself. Sofit_transformon an array or tensor scaled the first samples instead of the targets, and returned arrays with as many elements as there are targets.Xnever reachedtransform, so with aGroupNormalizeramong the normalizers the call failed witheither target_scale or X has to be passed.This adds
MultiNormalizer.fit_transform(y, X=None, return_norm=False). It fits onyasfitexpects, transposes an array or tensor fortransform(a DataFrame is left as it is), and passesXandreturn_normon. The result is the same as the explicitfit(y).transform(y.T)control in the issue. Nothing in the library callsMultiNormalizer.fit_transform(TimeSeriesDataSetusestransform), so existing code paths don't change.What should a reviewer concentrate their feedback on?
fit_transformshould keep the existingtransformlayout (one row per target for arrays/tensors), as done here, rather than changingtransform.Did you add any tests for the change?
Yes, in
tests/test_data/test_encoders.py:test_MultiNormalizer_fit_transform[numpy|torch|pandas]: every target keeps all 4 samples and equals aTorchNormalizerfitted on that target alone. numpy and torch fail onmain, pandas already passed.test_MultiNormalizer_fit_transform_passes_groups: with aGroupNormalizer, the first target equalsGroupNormalizer.fit_transform(data["a"], data). Fails onmainwith the assertion above.tests/test_data/test_encoders.py: 62 passed (Python 3.12, CPU torch 2.14.1). ruff 0.6.9 (the pre-commit version) check and format are clean.Any other comments?
Note: I used Claude Code while working on this.
PR checklist
pre-commit run)