sklearn.cross_validation.check_cv(cv, X=None, y=None, classifier=False)[source]

Input checker utility for building a CV in a user friendly way.

Deprecated since version 0.18: This module will be removed in 0.20. Use sklearn.model_selection.check_cv instead.


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

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

  • None, to use the default 3-fold cross-validation,
  • integer, to specify the number of folds.
  • An object to be used as a cross-validation generator.
  • An iterable yielding train/test splits.

For integer/None inputs, if classifier is True and y is binary or multiclass, StratifiedKFold is used. In all other cases, KFold is used.

Refer User Guide for the various cross-validation strategies that can be used here.

X : array-like

The data the cross-val object will be applied on.

y : array-like

The target variable for a supervised learning problem.

classifier : boolean optional

Whether the task is a classification task, in which case stratified KFold will be used.


checked_cv : a cross-validation generator instance.

The return value is guaranteed to be a cv generator instance, whatever the input type.