All problems
Time-Series Split Boundaries
Problem
Return expanding time-series split boundaries. For the i-th of n_splits folds, the test window ends at n - (n_splits - 1 - i) * test_size and is test_size points long, while everything before it is training. Each entry is [train_end, test_start, test_end] with train_end equal to test_start. Return [] unless n_splits > 0, test_size > 0, and n_splits * test_size < n.
Hint
Each fold trains only on the past and tests on the next fixed-size block of the future.
Test cases
case 1
in: [10,3,2]
expected: [[4,4,6],[6,6,8],[8,8,10]]
case 2
in: [6,2,2]
expected: [[2,2,4],[4,4,6]]
case 3
in: [5,5,1]
expected: []
case 4
in: [4,1,1]
expected: [[3,3,4]]
Starter codePython
def time_series_split_bounds(n, n_splits, test_size):
# Your code here
pass4 test cases · run your code against them in the editor