`model_selection.split_data_train_validation_test`: Test set starts one point too early

Open
#774 2 comments 0 reactions 1 assignee View on GitHub

Maintainers usually reply within 2 days

@egordm is already working on this.

Since Dec 16, 2025.

Assessment

This issue has not been assessed yet.

Description

fix

When calling model_selection.split_data_train_validation_test() in backtest mode, the test set starts one point too early. Assume you have a DataFrame of size 100, and test_fraction is 0.1.
Then start_date_test = end_date - np.round(number_indices * test_fraction) * delta (line 176) implies that the test set starts 10 time steps earlier than the last timestamp. So, because we have 100 timestamps in this simple example, the test set starts from timestamp 90. Due to this off-by-one-error, the actual test set size is 11, instead of the expected 10.

A simple fix would be to change line 176 in model_selection/model_selection.py to

start_date_test = end_date - (np.round(number_indices * test_fraction) - 1) * delta
Dominant language
Python
Stars
169
Forks
59
Avg merge
4d 15h
Merged PRs (30d)
8

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from OpenSTEF/openstef

All issues in OpenSTEF/openstef

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.