K-Fold Cross validation with different (merged) datasets

Solution 1:

from the documentation

cv: int, cross-validation generator or an iterable, default=None

An iterable yielding (train, test) splits as arrays of indices.

so you can create a list of tuples, and merge all the data into a single dataset while maintaining indicies to them that you can use in those tuples,

so if you have the indicies in a list of numpy arrays called indicies.

edit: this is untested but it should work.

indicies = []
train_test_set = []
last_element = 0
for j in range(len(datasets)):
    train_test_set.append(datasets[j])
    indicies.append(np.arange(last_element,last_element+len(datasets[j])))
    last_element += len(datasets[j])

cv_list = []
for i in range(15):
    cv_train = np.hstack([indicies[x] for x in range(15) if x != i])
    cv_list.append((cv_train,indicies[i]))

and just pass cv_list to the function.

Edit2: fixed typo in code.