fix(model): resolve cross-day batching issue in DailyBatchSampler - #2332
Conversation
|
Akshay Kumar Hudedmani (@akshaykumarhudedmani) please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.
Contributor License AgreementContribution License AgreementThis Contribution License Agreement (“Agreement”) is agreed to by the party signing below (“You”),
|
1 similar comment
|
Akshay Kumar Hudedmani (@akshaykumarhudedmani) please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.
Contributor License AgreementContribution License AgreementThis Contribution License Agreement (“Agreement”) is agreed to by the party signing below (“You”),
|
|
@microsoft-github-policy-service agree |
Description
Fixes #2319.
DailyBatchSamplerpreviously assumed that the dataset rows belonging to the same trading day were contiguous. However, since the dataset is instrument-major, it was silently yielding cross-day batches (one instrument across many consecutive days).This PR rewrites
DailyBatchSamplerto explicitly group by thedatetimeindex level, yielding batches that are true cross-sectional single days. Additionally, it properly re-aligns the prediction output in theGATs.predictmethod to match the new iteration order of the sampler.Motivation and Context
Fixes #2319. Training with cross-day batches completely invalidates cross-sectional models like GATs, as the graph/attention operates over a single stock's history rather than a single day's cross-section.
How Has This Been Tested?
pytest qlib/tests/test_all_pipeline.pyunder upper directory ofqlib.Screenshots of Test Results (if appropriate):
Pipeline test passed successfully. Validated locally via isolated sampler iteration test.
Types of changes