Skip to content

Fix daily batching for time-series samplers - #2322

Open
Serhii Ovsiienko (sergio12S) wants to merge 1 commit into
microsoft:mainfrom
sergio12S:fix/2319-daily-batching
Open

Fix daily batching for time-series samplers#2322
Serhii Ovsiienko (sergio12S) wants to merge 1 commit into
microsoft:mainfrom
sergio12S:fix/2319-daily-batching

Conversation

@sergio12S

Copy link
Copy Markdown

TSDataSampler.get_index() exposes datetime/instrument labels over an
instrument-major row layout. DailyBatchSampler previously calculated correct
per-date counts but converted them to contiguous ranges, so a nominal daily
batch could mix multiple dates.

I reproduced this with five dates and three instruments: every emitted batch
contained three distinct dates. This change groups the actual source-row
positions by datetime. Because that changes iteration order, predict() now
builds its result index from the sampler's order as well, preventing otherwise
correct predictions from being assigned to the wrong observations. __len__
now returns the number of daily batches.

The added regression test constructs a real TSDataSampler and checks batch
membership, sampler length, and output-index alignment.

Tested with:

python -m pytest -q tests/model/test_pytorch_gats_ts.py — 1 passed.

Closes #2319.

@koriyoshi2041 Parafee41 (koriyoshi2041) left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified at 1d58db7. Grouping source-row positions by datetime fixes the instrument-major layout bug, and using the same sampler order for the prediction index keeps values aligned. The regression covers daily membership, batch count, and index ordering; the focused test passes locally, and the diff check is clean.

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.

DailyBatchSampler in pytorch_gats_ts.py yields cross-day batches: TSDataSampler.get_index() swaps index labels but not row order

2 participants