Skip to content

Enhance TimestampSplit to support ratio-based data splitting#712

Merged
hieuddo merged 2 commits into
PreferredAI:masterfrom
MacchiatoCreamCheese:upgrade-timestampsplit
Jul 18, 2026
Merged

Enhance TimestampSplit to support ratio-based data splitting#712
hieuddo merged 2 commits into
PreferredAI:masterfrom
MacchiatoCreamCheese:upgrade-timestampsplit

Conversation

@MacchiatoCreamCheese

Copy link
Copy Markdown
Contributor

Description

Follow-up to #693. TimestampSplit now accepts ratios (test_size, val_size) and computes the timestamp cutoffs automatically, so users no longer have to find the exact cutoff values by hand. The absolute-cutoff API is unchanged — the timestamp args just became optional, and the mode is picked by which args are given.

TimestampSplit(data, test_size=0.2, val_size=0.1)                 # NEW: split by ratio
TimestampSplit(data, val_timestamp=..., test_timestamp=...)       # still works

Ratios are counted by number of interactions (like RatioSplit). Interactions sharing a boundary timestamp stay on one side to avoid leakage, so the realized ratio is approximate under tied timestamps.

Related Issues

Follow-up to #693 (original TimestampSplit), addressing #689.

Checklist:

  • I have added tests.
  • I have updated the documentation accordingly.
  • I have updated README.md (if you are adding a new model).
  • I have updated examples/README.md (if you are adding a new example).
  • I have updated datasets/README.md (if you are adding a new dataset).

@hieuddo

hieuddo commented Jul 18, 2026

Copy link
Copy Markdown
Member

Thank you for the PR! I pushed a few guards for edge cases:

  • ValueError when timestamp cutoffs and size ratios are mixed, the API expects either val_timestamp/test_timestamp or test_size/val_size, not both.
  • Clearer ValueError in ratio mode when tied timestamps would make train_set empty (previously the message referred to val_timestamp, which the user never passed).
  • UserWarning when val_size is requested but tied timestamps collapse the validation window, leaving val_set = None.
  • Docstring fix: sizes are treated as absolute counts when >= 1, not > 1.

@hieuddo hieuddo added the eval_methods Evaluation methods, data splitting and iterations label Jul 18, 2026
@hieuddo
hieuddo merged commit 4db147d into PreferredAI:master Jul 18, 2026
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

eval_methods Evaluation methods, data splitting and iterations

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants