[ENH] expose encoder scaling parameters and add inverse_scaling utility in TimeSeriesDataSet#2280
[ENH] expose encoder scaling parameters and add inverse_scaling utility in TimeSeriesDataSet#2280cngmid wants to merge 11 commits into
Conversation
|
Hi @andersendsa and @phoeenniixx — the initial implementation is ready for API review. This Draft PR currently includes only the core changes to
Looking forward to your feedback! |
phoeenniixx
left a comment
There was a problem hiding this comment.
Thanks! I think the code-quality is failing, please use pre-commit to solve this and other tests would run that would help us in reviewing as well
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2280 +/- ##
=======================================
Coverage ? 87.19%
=======================================
Files ? 167
Lines ? 9796
Branches ? 0
=======================================
Hits ? 8542
Misses ? 1254
Partials ? 0
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Check out this pull request on See visual diffs & provide feedback on Jupyter Notebooks. Powered by ReviewNB |
|
Hi, all requested changes have been implemented, including a test function and a notebook added to the |
|
All requested changes have been implemented, including the multi‑target fix, updated tests, and the revised tutorial. |
|
@phoeenniixx |
|
Hi @phoeenniixx — I’ve re‑requested your review. |
phoeenniixx
left a comment
There was a problem hiding this comment.
THanks! sorry for the late reply
Pinging @fkiraly @agobbifbk for their review. For me it looks good!
Fixes PR #2271
[ENH] Encoder scaling parameters and inverse-scaling in
TimeSeriesDataSetNote: This PR currently includes only the core implementation.
I will add tests and a tutorial notebook once the maintainers confirm the API and naming.
This avoids rewriting tests/tutorials if design changes are requested.
Summary
This PR introduces a set of enhancements to
TimeSeriesDataSetthat make encoder/decoder scaling fully transparent and invertible. The goal is to improve interpretability, debugging, and downstream analysis by exposing scaling parameters and providing a clean inverse‑scaling utility.These changes are fully backward‑compatible and optional for users who do not need custom scaling.
Motivation
TimeSeriesDataSetapplies scaling internally (e.g.,EncoderNormalizer,StandardScaler, or custom normalizers), but the resulting scale parameters are not currently exposed in a structured way. This makes it difficult to:inspect model inputs in their original units
debug model behavior
compare predictions to raw data
export interpretable results
mix sklearn scalers with internal normalizers
This PR addresses these limitations by exposing encoder scaling parameters and providing a robust inverse‑scaling mechanism.
What This PR Adds
1. Public access to encoder scaling parameters
The dataset now exposes:
x_scale (n_scalers, 2)— scale values used internally, andx_scale_idx (n_scalers,)— mapping from feature index → scale index.The corresponding dataloader exposes:
encoder_scale (n_batch, n_scalers, 2)— scale values used internally, andencoder_scale_idx (n_batch, n_scalers)— mapping from feature index → scale index.These attributes allow users to inspect exactly how each feature was scaled.
2. A general inverse‑scaling utility
When users define mixed scaling strategies:
a new method:
supports:
StandardScalerEncoderNormalizerunscaled features
per‑sample scale parameters
both dataset items and dataloader batches
This makes it easy to reconstruct original values for visualization, debugging, or exporting predictions.
3. A tutorial notebook
A new example notebook demonstrates:
creating a dataset with mixed scalers
inspecting encoder scaling parameters
inverse‑transforming dataset items
inverse‑transforming dataloader batches
validating reconstruction accuracy
visual comparison of original vs. reconstructed values
Example Usage
Inverse‑transforming a dataset item
Inverse‑transforming a batch
Backward Compatibility
Existing behavior is unchanged for users who do not pass custom scalers.
All new functionality is opt‑in.
No breaking API changes.
Next Steps
I’m happy to refine the API, add more tests, or adjust the tutorial based on maintainer feedback.
Thanks for reviewing — looking forward to iterating on this together.