WRITE · TRACE · UNDERSTAND

Cross-validation Folds

Partition indices without loss or overlap.

Your experiment

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

Python runs in your browser. Your draft stays on this device.

What to look for

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

Watch your code work

Ready to experiment

Write a solution or load the worked answer, then choose Trace & check.

Step through arrays, variables and training curves produced by your own Python.