Cross-Validation
Consider an example where you split your data into five parts of 20% each. You would then make use of four parts for training and one part for evaluation. Because you have five parts, you can make use of the data five times, each time using one part for validation and the remaining data for training.
Cross-validation is an approach to splitting your data where you make multiple splits and then make use of some of them for training and the rest for validation. You then make use of all of the combinations of data to train multiple models.
This approach is called n-fold cross-validation or k-fold cross-validation.
Note
For more information on k-fold cross-validation, refer to https://packt.live/36eXyfi.
KFold
The KFold
class in sklearn.model_selection
returns a generator that provides a tuple with two indices, one for training and another for testing or validation. A generator function lets you declare...