# sklearn.model_selection: GridSearchCV vs. KFold

Here is the explain of cv parameter in the sklearn.model_selection.GridSearchCV:

cv : int, cross-validation generator or an iterable, optional

Determines the cross-validation splitting strategy. Possible inputs for cv are:

• integer, to specify the number of folds in a (Stratified)KFold

For example, can I replace

CV = 5


to

CV = KFold(n_splits=5, random_state=None, shuffle=False)


or replace in the opposite way. CV is called in the function

GridSearchCV(estimator=XXX, ... , cv = CV)


I am not sure whether any difference?

Yes, you can replace the cv=5 with cv=KFold(n_splits=5, random_state=None, shuffle=False). Leaving it set to an integer, like 5, is the equivalent of setting it to either KFold(n_splits=5) or StratifiedKFold(n_splits=5), depending on the model you pass to the estimator parameter of GridSearchCV()