Reputation: 315
I would like to use GridSearchCV for parameter tuning and evaluation over 10 predefined selected folds of data that I have (as list of lists of data indices).
Does anyone know how to feed GridSearchCV in scikit with 10 lists of predefined test folds?
splits=[ [0,10,9,1,2,..] ,[3,5,7,..],[23,4,34,..]]
#len(split)=10
greed_search = GridSearchCV(estimator, param_grid=parameters, cv=splits,scoring=scoring, refit=score, error_score=0, n_jobs=n_jobs)
Upvotes: 1
Views: 479
Reputation: 5027
I think that you need to preprocess your folds a little bit like this:
new_splits = []
for i in range(len(splits)):
train = [j for i in splits[:i] + splits[i + 1:] for j in i]
test = splits[i]
new_splits.append([train, test])
To get not only test parts in iterable, but also train part as well
Upvotes: 2