Your question is Cross-Validation in Python. Start with the requirements on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
H2O-3 evaluates models across multiple folds to estimate generalization performance. Implement the split-generation portion of k-fold cross-validation without using machine learning libraries.
Given a feature matrix X, label array y, number of folds k, and optional shuffling parameters, return the train and validation indices for every fold. Each sample must appear in exactly one validation set, while every training set contains all samples not assigned to that fold.
Implement cross_validate(X, y, k, shuffle, seed):
X is a list of feature rows. Its values are not used when creating indices.y is a list of labels with the same length as X.k is an integer between 2 and len(X).shuffle is a Boolean. If false, preserve the original index order. If true, shuffle indices using seed.seed is an integer or None.k dictionaries. Each dictionary must contain train, a list of indices, and validation, a list of indices.Validation folds should be as balanced as possible. Earlier folds receive one extra sample when the dataset size is not divisible by k. Do not mutate X or y.
def cross_validate(X, y, k, shuffle, seed):