[ENH] Add preprocessing (scalers and normalizers) to tslib datamodule - #2368
Open
echo-xiao wants to merge 7 commits into
Open
[ENH] Add preprocessing (scalers and normalizers) to tslib datamodule#2368echo-xiao wants to merge 7 commits into
echo-xiao wants to merge 7 commits into
Conversation
Add test_no_scalers_leaves_data_untouched to guard backward compatibility: when no scalers are configured, continuous features pass through untouched and target_scale is absent from the preprocessed output.
echo-xiao
requested review from
benHeid,
fkiraly,
jdb78 and
phoeenniixx
as code owners
August 3, 2026 21:51
Contributor
Author
|
hi, @phoeenniixx please review these and let me know if these decisions are right:
TODO:
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2368 +/- ##
=======================================
Coverage ? 86.69%
=======================================
Files ? 175
Lines ? 10292
Branches ? 0
=======================================
Hits ? 8923
Misses ? 1369
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:
|
phoeenniixx
reviewed
Aug 4, 2026
|
|
||
|
|
||
| def _make_ts(n_series: int = 20, length: int = 40, offset: float = 100.0) -> TimeSeries: | ||
| """合成数据集:连续特征 ``x`` 远离 0(~offset),便于看出标准化;目标 ``y`` 是正弦。""" |
Member
There was a problem hiding this comment.
please use english docstrings
phoeenniixx
requested changes
Aug 4, 2026
phoeenniixx
left a comment
Member
There was a problem hiding this comment.
Nice!
I have a few questions:
- Did you look at the
thumlimplementation? I think we should try to keep it as close to this package as possible - when it comes to the preprocessing logic as this dm is based on this package- Currently it supports all the scalers and normalizers that
EncoderDecoderDataModulesupports, but is this true for thetslibimplementation as well?
- Currently it supports all the scalers and normalizers that
Also, please use english docstrings, to maintain uniformity across the documentation.
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 #2330.
What does this implement/fix? Explain your changes.
TslibDataModuleacceptedscalers/target_normalizerbut never used them(stored and ignored). This makes them functional, following #2302 and reusing
ScalerAdapter:__init__wraps them inScalerAdapter, adds_*_fittedflags and aper-series
_preprocess_cache._fit_scalers/_fit_target_normalizerfit on the train split only._normalize_features/_normalize_targettransform per series (no-op untilfitted; only configured continuous columns).
_preprocess_dataapplies the transforms and caches per series;setup("fit")fits on_train_indices.What should a reviewer concentrate their feedback on?
target_scale** to a follow-upDid you add any tests for the change?
Yes — 7 tests in
pytorch_forecasting/data/tests/test_tslib_data_module.py:_preprocess_datascaling + cache identity;setup("fit")produces scaled samples;target_scale).PR checklist
pre-commit run --fileson both changed files, clean).