Loading...
Generate the train and validation index splits for K-Fold cross-validation.
Given n data points and k folds, divide indices [0,1,...,n−1] into k approximately equal folds. For each fold i, use fold i as validation and the remaining folds as training.
Return a list of k tuples: [(train_indices, val_indices), ...] where each set of indices is a sorted list.
Split the indices sequentially (first n//k go to fold 0, next to fold 1, etc.). If n is not evenly divisible, the first nmodk folds get one extra element.
n = 5, k = 3
[([2, 3, 4], [0, 1]), ([0, 1, 4], [2, 3]), ([0, 1, 2, 3], [4])]
[([2, 3, 4], [0, 1]), ([0, 1, 4], [2, 3]), ([0, 1, 2, 3], [4])]