K-fold cross-validation works by dividing the training dataset into k equal folds and improve hold out method. Then, the learning model is trained on k-1 folds and tested by the hold out method on the remaining fold of the k-fold cross-validation. This process is repeated k times, with each fold being used as the test set once like the holdout method. Then, the performance of the model is averaged across the k iterations at the end of the hold out method in a k-fold cross-validation.