Skip to content

Conversation

@ravjot07
Copy link

This PR implements target normalization and continuous feature scaling in the EncoderDecoderTimeSeriesDataModule._preprocess_data() method, addressing the TODO comment and completing a critical roadmap item for the PyTorch Forecasting v2 API rework.

Changes

Core Implementation (pytorch_forecasting/data/data_module.py)

  1. Target Normalization:

    • Applied target_normalizer (if provided) to normalize target values
    • Supports TorchNormalizer instances with automatic fitting
    • Stores normalization parameters (target_scale) in the result for inverse transformation during prediction
    • Handles both target_normalizer and _target_normalizer attributes (for "auto" case)
  2. Continuous Feature Scaling:

    • Applied scalers from scalers dictionary to continuous features
    • Supports both scikit-learn scalers (StandardScaler, RobustScaler) and PyTorch normalizers (TorchNormalizer, EncoderNormalizer)
    • Feature lookup by name (from metadata) or by index
    • Automatic fitting if scalers are not already fitted
    • Proper handling of numpy arrays (sklearn) vs tensors (torch normalizers)
  3. Return Type Update:

    • Changed return type from list[dict[str, Any]] to dict[str, Any] (single dictionary)
    • Updated method signature and docstring

Solves #1995

- Implement target normalization with TorchNormalizer
- Add continuous feature scaling support (StandardScaler, RobustScaler, TorchNormalizer)
- Store target_scale parameters for inverse transformation
- Update return type from list[dict] to dict
- Maintain backward compatibility (scalers are optional)
Signed-off-by: ravjot07 <ravu2004@gmail.com>
Signed-off-by: ravjot07 <ravu2004@gmail.com>
@ravjot07 ravjot07 marked this pull request as draft November 30, 2025 18:21
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.

1 participant