PythiloLesson 5 of 12 · progress kept in this browser

Cross-validation Folds

Partition indices without loss or overlap. Earlier folds receive the remainder; every validation item is excluded from its training fold.

indices = list(range(5))
validation = indices[:3]
training = indices[3:]
print(training, validation)
Your task

folds(n, k) returns k (training_indices, validation_indices) pairs with consecutive validation blocks. 1 <= k <= n. Put extra items in the earliest folds.