A given data set is divided into K sections or folds, and each fold serves as a testing set at some point in the KFold CV. Take the 5Fold CrossValidation (K=5) example. The data set is divided into five folds in this case.

The first fold is utilized in the first iteration to test the model, while the remaining folds are used to train the model.

The second iteration uses the second fold as the testing set and the remaining data as the training set.
Up until all five of the folds have been employed as the testing set, this process is repeated.