[ENH] Add augmentation support to `TslibDataModule` #2494
All Vouch review confidence checks passed
Residual risk 0.25 = Change Risk (0.43) × (1 − Review Confidence (0.43)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.43 · 399 lines diff across 4 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.358
Shallow Review Depth
shallow_review_depth
0.344
Real PR Conversation Timeline
1 comments
"Review active on #2494"
general
weight: 0.35
phoeenniixx
Reference Issues/PRs
Fixes #2417. Split out of #2330.
What does this implement/fix? Explain your changes.
| File | What it contains |
|---|---|
|
pytorch_forecasting/data/augmentation.py| New module:BaseAugmentation,resample_positions, a torch DTW core, the 8 per-sample transforms, the 6 label-guided transforms, andNeighbourIndex||
tests/test_data/test_augmentation.py| New test module, 106 tests ||
pytorch_forecasting/data/data_module/_tslib_data_module.py|__getitem__split into_slice_window/_augment/_assemble; theaugmentationandaugmentation_labelparameters; train-only wiring insetup;_build_neighbour_index||
pytorch_forecasting/data/__init__.py| Exports the 15 public names ||
docs/source/data_v2.rst| Autosummary entries and a line on augmentation in the D2 layer section ||
pytorch_forecasting/data/tests/test_tslib_data_module.py| One test pinning that the__getitem__split is behaviour-preserving |What should a reviewer concentrate their feedback on?
See #2417.
Did you add any tests for the change?
| Area | What is pinned |
|---|---|
|
resample_positions| Continuous and target blocks interpolate; categorical codes snap to the nearest step; out-of-range positions clamp rather than wrap; the split lengths survive || Every transform | Changes the data; preserves all three block shapes; never mutates the input; reproducible for one seed and different across seeds |
| Time-axis alignment | After any resampling the categorical block still describes the same timestep as the continuous one — the guarantee
resample_positionsexists for || Per-transform behaviour |
Scalingholds one factor per channel constant over time;SignFlipdoes not permute feature columns;Permutationis a true permutation of the original steps;TimeWarpshares one warp across channels;WindowSlicecovers a sub-span || DTW core | Self-alignment is the diagonal; the path is monotone and covers both series end to end; the Sakoe-Chiba band constrains it; empty input raises;
shape_dtwis not the pointwise distance || Train-only | The transform reaches
train_datasetand no other split; default-off leaves every split unaugmented || Wiring | A single transform and a list are both accepted, and a list applies in order; the same index is resampled afresh on every access |
| Neighbour pool | Built only when a transform declares
requires_neighbours; a neighbour always comes from a different series; the other-label draw really differs in label; a label covering one series raises when the index is built;as_arrayexcludes the categorical block || Public API | All 14 transforms plus
BaseAugmentationimport frompytorch_forecasting.data|| Through a real dataloader | An augmented batch collates and is finite, validation stays byte-identical to the unaugmented module, and
seed_everythingmakes an epoch reproducible |PR checklist