diff --git a/sklearn/calibration.py b/sklearn/calibration.py index a7b561406e106..4607fcba988fd 100644 --- a/sklearn/calibration.py +++ b/sklearn/calibration.py @@ -53,10 +53,21 @@ class CalibratedClassifierCV(BaseEstimator, ClassifierMixin): with too few calibration samples (<<1000) since it tends to overfit. Use sigmoids (Platt's calibration) in this case. - cv : integer or cross-validation generator or "prefit", optional - If an integer is passed, it is the number of folds (default 3). - Specific cross-validation objects can be passed, see - sklearn.cross_validation module for the list of possible objects. + cv : integer/cross-validation generator/iterable or "prefit", 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 ``y`` is binary or multiclass, + :class:`StratifiedKFold` used. If ``y`` is neither binary nor + multiclass, :class:`KFold` is used. + + Refer :ref:`User Guide ` for the various + cross-validation strategies that can be used here. + If "prefit" is passed, it is assumed that base_estimator has been fitted already and all data is used for calibration. diff --git a/sklearn/covariance/graph_lasso_.py b/sklearn/covariance/graph_lasso_.py index 91b98a8dc6bfc..6957507a336a0 100644 --- a/sklearn/covariance/graph_lasso_.py +++ b/sklearn/covariance/graph_lasso_.py @@ -463,9 +463,18 @@ class GraphLassoCV(GraphLasso): The number of times the grid is refined. Not used if explicit values of alphas are passed. - cv : cross-validation generator, optional - see sklearn.cross_validation module. If None is passed, defaults to - a 3-fold strategy + 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 :class:`KFold` is used. + + Refer :ref:`User Guide ` for the various + cross-validation strategies that can be used here. tol: positive float, optional The tolerance to declare convergence: if the dual gap goes below diff --git a/sklearn/cross_validation.py b/sklearn/cross_validation.py index 117327dbc814a..14203b1dad2d5 100644 --- a/sklearn/cross_validation.py +++ b/sklearn/cross_validation.py @@ -1202,15 +1202,20 @@ def cross_val_predict(estimator, X, y=None, cv=None, n_jobs=1, The target variable to try to predict in the case of supervised learning. - cv : integer or cross-validation generator, optional, default=3 - A cross-validation generator to use. If int, determines the number - of folds in StratifiedKFold if estimator is a classifier and the - target y is binary or multiclass, or the number of folds in KFold - otherwise. - Specific cross-validation objects can be passed, see - sklearn.cross_validation module for the list of possible objects. - This generator must include all elements in the test set exactly once. - Otherwise, a ValueError is raised. + 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 ``y`` is binary or multiclass, + :class:`StratifiedKFold` used. If the estimator is a classifier + or if ``y`` is neither binary nor multiclass, :class:`KFold` is used. + + Refer :ref:`User Guide ` for the various + cross-validation strategies that can be used here. n_jobs : integer, optional The number of CPUs to use to do the computation. -1 means @@ -1371,13 +1376,20 @@ def cross_val_score(estimator, X, y=None, scoring=None, cv=None, n_jobs=1, a scorer callable object / function with signature ``scorer(estimator, X, y)``. - cv : integer or cross-validation generator, optional, default=3 - A cross-validation generator to use. If int, determines the number - of folds in StratifiedKFold if estimator is a classifier and the - target y is binary or multiclass, or the number of folds in KFold - otherwise. - Specific cross-validation objects can be passed, see - sklearn.cross_validation module for the list of possible objects. + 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 ``y`` is binary or multiclass, + :class:`StratifiedKFold` used. If the estimator is a classifier + or if ``y`` is neither binary nor multiclass, :class:`KFold` is used. + + Refer :ref:`User Guide ` for the various + cross-validation strategies that can be used here. n_jobs : integer, optional The number of CPUs to use to do the computation. -1 means @@ -1628,11 +1640,20 @@ def check_cv(cv, X=None, y=None, classifier=False): Parameters ---------- - cv : int, a cv generator instance, or None - The input specifying which cv generator to use. It can be an - integer, in which case it is the number of folds in a KFold, - None, in which case 3 fold is used, or another object, that - will then be used as a cv generator. + 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 ``y`` is binary or multiclass, + :class:`StratifiedKFold` used. If the estimator is a classifier + or if ``y`` is neither binary nor multiclass, :class:`KFold` is used. + + Refer :ref:`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. @@ -1692,13 +1713,20 @@ def permutation_test_score(estimator, X, y, cv=None, a scorer callable object / function with signature ``scorer(estimator, X, y)``. - cv : integer or cross-validation generator, optional, default=3 - A cross-validation generator to use. If int, determines the number - of folds in StratifiedKFold if estimator is a classifier and the - target y is binary or multiclass, or the number of folds in KFold - otherwise. - Specific cross-validation objects can be passed, see - sklearn.cross_validation module for the list of possible objects. + 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 ``y`` is binary or multiclass, + :class:`StratifiedKFold` used. If the estimator is a classifier + or if ``y`` is neither binary nor multiclass, :class:`KFold` is used. + + Refer :ref:`User Guide ` for the various + cross-validation strategies that can be used here. n_permutations : integer, optional Number of times to permute ``y``. diff --git a/sklearn/feature_selection/rfe.py b/sklearn/feature_selection/rfe.py index 1119e1a22f25a..9905dca55d1a3 100644 --- a/sklearn/feature_selection/rfe.py +++ b/sklearn/feature_selection/rfe.py @@ -290,11 +290,20 @@ class RFECV(RFE, MetaEstimatorMixin): If within (0.0, 1.0), then `step` corresponds to the percentage (rounded down) of features to remove at each iteration. - cv : int or cross-validation generator, optional (default=None) - If int, it is the number of folds. - If None, 3-fold cross-validation is performed by default. - Specific cross-validation objects can also be passed, see - `sklearn.cross_validation module` for details. + 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 ``y`` is binary or multiclass, + :class:`StratifiedKFold` used. If the estimator is a classifier + or if ``y`` is neither binary nor multiclass, :class:`KFold` is used. + + Refer :ref:`User Guide ` for the various + cross-validation strategies that can be used here. scoring : string, callable or None, optional, default: None A string (see model evaluation documentation) or diff --git a/sklearn/grid_search.py b/sklearn/grid_search.py index 8c88d6145d4fe..540df8d078d47 100644 --- a/sklearn/grid_search.py +++ b/sklearn/grid_search.py @@ -656,13 +656,20 @@ class GridSearchCV(BaseSearchCV): the folds, and the loss minimized is the total loss per sample, and not the mean loss across the folds. - cv : integer or cross-validation generator, default=3 - A cross-validation generator to use. If int, determines - the number of folds in StratifiedKFold if estimator is a classifier - and the target y is binary or multiclass, or the number - of folds in KFold otherwise. - Specific cross-validation objects can be passed, see - sklearn.cross_validation module for the list of possible objects. + 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 ``y`` is binary or multiclass, + :class:`StratifiedKFold` used. If the estimator is a classifier + or if ``y`` is neither binary nor multiclass, :class:`KFold` is used. + + Refer :ref:`User Guide ` for the various + cross-validation strategies that can be used here. refit : boolean, default=True Refit the best estimator with the entire dataset. @@ -850,13 +857,20 @@ class RandomizedSearchCV(BaseSearchCV): the folds, and the loss minimized is the total loss per sample, and not the mean loss across the folds. - cv : integer or cross-validation generator, optional - A cross-validation generator to use. If int, determines - the number of folds in StratifiedKFold if estimator is a classifier - and the target y is binary or multiclass, or the number - of folds in KFold otherwise. - Specific cross-validation objects can be passed, see - sklearn.cross_validation module for the list of possible objects. + 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 ``y`` is binary or multiclass, + :class:`StratifiedKFold` used. If the estimator is a classifier + or if ``y`` is neither binary nor multiclass, :class:`KFold` is used. + + Refer :ref:`User Guide ` for the various + cross-validation strategies that can be used here. refit : boolean, default=True Refit the best estimator with the entire dataset. diff --git a/sklearn/learning_curve.py b/sklearn/learning_curve.py index 9c9b29b24dedb..ae5601483c8fc 100644 --- a/sklearn/learning_curve.py +++ b/sklearn/learning_curve.py @@ -59,13 +59,20 @@ def learning_curve(estimator, X, y, train_sizes=np.linspace(0.1, 1.0, 5), be big enough to contain at least one sample from each class. (default: np.linspace(0.1, 1.0, 5)) - cv : integer or cross-validation generator, optional, default=3 - A cross-validation generator to use. If int, determines the number - of folds in StratifiedKFold if estimator is a classifier and the - target y is binary or multiclass, or the number of folds in KFold - otherwise. - Specific cross-validation objects can be passed, see - sklearn.cross_validation module for the list of possible objects. + 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 ``y`` is binary or multiclass, + :class:`StratifiedKFold` used. If the estimator is a classifier + or if ``y`` is neither binary nor multiclass, :class:`KFold` is used. + + Refer :ref:`User Guide ` for the various + cross-validation strategies that can be used here. scoring : string, callable or None, optional, default: None A string (see model evaluation documentation) or @@ -264,10 +271,20 @@ def validation_curve(estimator, X, y, param_name, param_range, cv=None, param_range : array-like, shape (n_values,) The values of the parameter that will be evaluated. - cv : integer, cross-validation generator, optional - If an integer is passed, it is the number of folds (defaults to 3). - Specific cross-validation objects can be passed, see - sklearn.cross_validation module for the list of possible objects + 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 ``y`` is binary or multiclass, + :class:`StratifiedKFold` used. If the estimator is a classifier + or if ``y`` is neither binary nor multiclass, :class:`KFold` is used. + + Refer :ref:`User Guide ` for the various + cross-validation strategies that can be used here. scoring : string, callable or None, optional, default: None A string (see model evaluation documentation) or diff --git a/sklearn/linear_model/coordinate_descent.py b/sklearn/linear_model/coordinate_descent.py index e750fd2c95929..ea0ff541bfff6 100644 --- a/sklearn/linear_model/coordinate_descent.py +++ b/sklearn/linear_model/coordinate_descent.py @@ -1221,11 +1221,18 @@ class LassoCV(LinearModelCV, RegressorMixin): dual gap for optimality and continues until it is smaller than ``tol``. - cv : integer or cross-validation generator, optional - If an integer is passed, it is the number of fold (default 3). - Specific cross-validation objects can be passed, see the - :mod:`sklearn.cross_validation` module for the list of possible - objects. + 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, :class:`KFold` is used. + + Refer :ref:`User Guide ` for the various + cross-validation strategies that can be used here. verbose : bool or integer Amount of verbosity. @@ -1360,11 +1367,18 @@ class ElasticNetCV(LinearModelCV, RegressorMixin): dual gap for optimality and continues until it is smaller than ``tol``. - cv : integer or cross-validation generator, optional - If an integer is passed, it is the number of fold (default 3). - Specific cross-validation objects can be passed, see the - :mod:`sklearn.cross_validation` module for the list of possible - objects. + 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, :class:`KFold` is used. + + Refer :ref:`User Guide ` for the various + cross-validation strategies that can be used here. verbose : bool or integer Amount of verbosity. @@ -1835,11 +1849,18 @@ class MultiTaskElasticNetCV(LinearModelCV, RegressorMixin): dual gap for optimality and continues until it is smaller than ``tol``. - cv : integer or cross-validation generator, optional - If an integer is passed, it is the number of fold (default 3). - Specific cross-validation objects can be passed, see the - :mod:`sklearn.cross_validation` module for the list of possible - objects. + 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, :class:`KFold` is used. + + Refer :ref:`User Guide ` for the various + cross-validation strategies that can be used here. verbose : bool or integer Amount of verbosity. @@ -1985,11 +2006,18 @@ class MultiTaskLassoCV(LinearModelCV, RegressorMixin): dual gap for optimality and continues until it is smaller than ``tol``. - cv : integer or cross-validation generator, optional - If an integer is passed, it is the number of fold (default 3). - Specific cross-validation objects can be passed, see the - :mod:`sklearn.cross_validation` module for the list of possible - objects. + 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, :class:`KFold` is used. + + Refer :ref:`User Guide ` for the various + cross-validation strategies that can be used here. verbose : bool or integer Amount of verbosity. diff --git a/sklearn/linear_model/least_angle.py b/sklearn/linear_model/least_angle.py index 5feb0cd1ca3c8..7abf632f3fca9 100644 --- a/sklearn/linear_model/least_angle.py +++ b/sklearn/linear_model/least_angle.py @@ -979,9 +979,18 @@ class LarsCV(Lars): max_iter: integer, optional Maximum number of iterations to perform. - cv : cross-validation generator, optional - see :mod:`sklearn.cross_validation`. If ``None`` is passed, default to - a 5-fold strategy + 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, :class:`KFold` is used. + + Refer :ref:`User Guide ` for the various + cross-validation strategies that can be used here. max_n_alphas : integer, optional The maximum number of points on the path used to compute the @@ -1167,9 +1176,18 @@ class LassoLarsCV(LarsCV): max_iter : integer, optional Maximum number of iterations to perform. - cv : cross-validation generator, optional - see sklearn.cross_validation module. If None is passed, default to - a 5-fold strategy + 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, :class:`KFold` is used. + + Refer :ref:`User Guide ` for the various + cross-validation strategies that can be used here. max_n_alphas : integer, optional The maximum number of points on the path used to compute the diff --git a/sklearn/linear_model/omp.py b/sklearn/linear_model/omp.py index 40ce91e56612c..589939ed7858f 100644 --- a/sklearn/linear_model/omp.py +++ b/sklearn/linear_model/omp.py @@ -755,9 +755,18 @@ class OrthogonalMatchingPursuitCV(LinearModel, RegressorMixin): Maximum numbers of iterations to perform, therefore maximum features to include. 10% of ``n_features`` but at least 5 if available. - cv : cross-validation generator, optional - see :mod:`sklearn.cross_validation`. If ``None`` is passed, default to - a 5-fold strategy + 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, :class:`KFold` is used. + + Refer :ref:`User Guide ` for the various + cross-validation strategies that can be used here. n_jobs : integer, optional Number of CPUs to use during the cross validation. If ``-1``, use diff --git a/sklearn/linear_model/ridge.py b/sklearn/linear_model/ridge.py index 3919d9914daae..9480c575de1d0 100644 --- a/sklearn/linear_model/ridge.py +++ b/sklearn/linear_model/ridge.py @@ -915,12 +915,19 @@ class RidgeCV(_BaseRidgeCV, RegressorMixin): a scorer callable object / function with signature ``scorer(estimator, X, y)``. - cv : integer or cross-validation generator, optional - If None, Generalized Cross-Validation (efficient Leave-One-Out) - will be used. - If an integer is passed, it is the number of folds for KFold cross - validation. Specific cross-validation objects can be passed, see - sklearn.cross_validation module for the list of possible objects + 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 ``y`` is binary or multiclass, + :class:`StratifiedKFold` used, else, :class:`KFold` is used. + + Refer :ref:`User Guide ` for the various + cross-validation strategies that can be used here. gcv_mode : {None, 'auto', 'svd', eigen'}, optional Flag indicating which strategy to use when performing @@ -1001,9 +1008,16 @@ class RidgeClassifierCV(LinearClassifierMixin, _BaseRidgeCV): a scorer callable object / function with signature ``scorer(estimator, X, y)``. - cv : cross-validation generator, optional - If None, Generalized Cross-Validation (efficient Leave-One-Out) - will be used. + cv : int, cross-validation generator or an iterable, optional + Determines the cross-validation splitting strategy. + Possible inputs for cv are: + - None, to use the efficient Leave-One-Out 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. + + Refer :ref:`User Guide ` for the various + cross-validation strategies that can be used here. class_weight : dict or 'balanced', optional Weights associated with classes in the form ``{class_label: weight}``.