Skip to content

fix(quantlib): support multi-segment test sets and guard empty training partitions in CV - #1204

Open
santhreal wants to merge 1 commit into
HKUDS:mainfrom
santhreal:fix/quantlib-group-purged-empty-fold
Open

fix(quantlib): support multi-segment test sets and guard empty training partitions in CV#1204
santhreal wants to merge 1 commit into
HKUDS:mainfrom
santhreal:fix/quantlib-group-purged-empty-fold

Conversation

@santhreal

Copy link
Copy Markdown
Contributor

Summary

Fixes combinatorial purged cross-validation splits where holding out multiple non-contiguous test blocks caused purge & embargo to treat the entire span as test, purging all training observations. Also guards against empty training folds under heavy embargo.

Changes

  • Updated _apply_purge_and_embargo and detect_boundary_leakage in agent/src/quantlib/crossvalidation.py to identify and process individual contiguous test segments.
  • Added explicit guard raising ValueError when purge and embargo eliminates all training observations in a fold.
  • Added regression tests in agent/tests/quantlib/test_crossvalidation.py.

Signed-off-by: santhreal 64453045+santhreal@users.noreply.github.com

…ng partitions in CV

Enhance _apply_purge_and_embargo and detect_boundary_leakage to handle
non-contiguous held-out test blocks in combinatorial purged splits, and guard
empty training sets under heavy embargo.

Signed-off-by: santhreal <64453045+santhreal@users.noreply.github.com>

@he-yufeng he-yufeng left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Verified this one end to end, and it is a real fix. Reproduction on current main with two non-contiguous test blocks ({2} and {9}) and one-period labels: the span logic purges 8 of 12 observations, wiping the gap training points 4..7; this branch purges only the 4 adjacent ones, which is the correct semantics. The contiguous-segment split in _apply_purge_and_embargo is sound, the empty-test-mask early return fixes a latent index-out-of-range on the old first_test lookup, and the empty-training-fold guard is a good addition. test_crossvalidation.py passes (36) on the branch.

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.

2 participants