Skip to content

Normalize decoder targets when using EncoderNormalizer - #2457

Open
HarshRajSinghania wants to merge 2 commits into
sktime:mainfrom
HarshRajSinghania:fix/encoder-normalizer-decoder-target
Open

HarshRajSinghania wants to merge 2 commits into
sktime:mainfrom
HarshRajSinghania:fix/encoder-normalizer-decoder-target

Conversation

@HarshRajSinghania

Copy link
Copy Markdown

Summary
Normalize decoder targets when EncoderDecoderTimeSeriesDataModule uses a per-sequence target normalizer (EncoderNormalizer).

Motivation
Fixes #2360. The dataset fitted EncoderNormalizer on the encoder window and applied it only to target_past. y stayed on the raw scale, so the training target did not match the normalized encoder history.

Implementation

  • Add ScalerAdapter.transform_sequence, which reuses the state just fitted by fit_transform_sequence and does not re-fit.
  • In the dataset __getitem__, fit on the encoder window and transform both target_past and the decoder target with that state. The forecast horizon is not used to fit the scale.
  • Non-per-sequence columns are left unchanged, matching the existing sequence helper.

Testing

  • python -m pytest tests/test_data/test_data_module.py -q -o addopts= — 43 passed, including new test_encoder_normalizer_scales_decoder_target.
  • ruff check on the changed adapter, data module, and test file passed.

The regression test checks that y and target_past match standard scaling fitted on the encoder window only (mean and unbiased std, plus float epsilon).

EncoderDecoderTimeSeriesDataModule fitted EncoderNormalizer on the encoder window and applied it only to target_past. Decoder y stayed on the raw scale. Fit on the encoder window and transform y with that state so the forecast horizon is not used to fit the scale.

Fixes sktime#2360
@codecov

codecov Bot commented Oct 9, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 88.88889% with 2 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (main@e437602). Learn more about missing BASE report.

Files with missing lines Patch % Lines
pytorch_forecasting/adapters/scaler_adapters.py 85.71% 2 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2457   +/-   ##
=======================================
  Coverage        ?   88.82%           
=======================================
  Files           ?      218           
  Lines           ?    11687           
  Branches        ?        0           
=======================================
  Hits            ?    10381           
  Misses          ?     1306           
  Partials        ?        0           
Flag Coverage Δ
cpu 88.82% <88.88%> (?)
pytest 88.82% <88.88%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

EncoderDecoderTimeSeriesDataModule fitted EncoderNormalizer on the encoder window only, so y stayed on the raw scale. Apply that same fit to the decoder target.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] y not being normalized when using EncoderNormalizer in EncoderDecoderDataModule

1 participant