fix(quantlib): support multi-segment test sets and guard empty training partitions in CV - #1204
Open
santhreal wants to merge 1 commit into
Open
fix(quantlib): support multi-segment test sets and guard empty training partitions in CV#1204santhreal wants to merge 1 commit into
santhreal wants to merge 1 commit into
Conversation
…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
reviewed
Aug 25, 2026
he-yufeng
left a comment
Collaborator
There was a problem hiding this comment.
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
_apply_purge_and_embargoanddetect_boundary_leakageinagent/src/quantlib/crossvalidation.pyto identify and process individual contiguous test segments.ValueErrorwhen purge and embargo eliminates all training observations in a fold.agent/tests/quantlib/test_crossvalidation.py.Signed-off-by: santhreal 64453045+santhreal@users.noreply.github.com