From 3e55d6e15af84326e3642b111793f546d0fef5dc Mon Sep 17 00:00:00 2001 From: Alex Itkes <38556752+alexitkes@users.noreply.github.com> Date: Tue, 23 Jul 2019 23:23:09 +0300 Subject: [PATCH 01/15] Document default values for linear module parameters. --- sklearn/linear_model/ridge.py | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/sklearn/linear_model/ridge.py b/sklearn/linear_model/ridge.py index b156b0394bb16..aaf174dd01234 100644 --- a/sklearn/linear_model/ridge.py +++ b/sklearn/linear_model/ridge.py @@ -314,10 +314,10 @@ def ridge_regression(X, y, alpha, sample_weight=None, solver='auto', by scipy.sparse.linalg. For 'sag' and saga solver, the default value is 1000. - tol : float + tol : float, default 1e-3 Precision of the solution. - verbose : int + verbose : int, default 0 Verbosity level. Setting verbose > 0 will display additional information depending on the solver used. @@ -619,7 +619,7 @@ class Ridge(MultiOutputMixin, RegressorMixin, _BaseRidge): Parameters ---------- - alpha : {float, array-like}, shape (n_targets) + alpha : {float, array-like}, shape (n_targets), default 1.0 Regularization strength; must be a positive float. Regularization improves the conditioning of the problem and reduces the variance of the estimates. Larger values specify stronger regularization. @@ -649,7 +649,7 @@ class Ridge(MultiOutputMixin, RegressorMixin, _BaseRidge): For 'sparse_cg' and 'lsqr' solvers, the default value is determined by scipy.sparse.linalg. For 'sag' solver, the default value is 1000. - tol : float + tol : float, default 1e-3 Precision of the solution. solver : {'auto', 'svd', 'cholesky', 'lsqr', 'sparse_cg', 'sag', 'saga'} @@ -771,14 +771,14 @@ class RidgeClassifier(LinearClassifierMixin, _BaseRidge): Parameters ---------- - alpha : float + alpha : float, default 1.0 Regularization strength; must be a positive float. Regularization improves the conditioning of the problem and reduces the variance of the estimates. Larger values specify stronger regularization. Alpha corresponds to ``C^-1`` in other linear models such as LogisticRegression or LinearSVC. - fit_intercept : boolean + fit_intercept : boolean, default True Whether to calculate the intercept for this model. If set to false, no intercept will be used in calculations (e.g. data is expected to be already centered). @@ -798,7 +798,7 @@ class RidgeClassifier(LinearClassifierMixin, _BaseRidge): Maximum number of iterations for conjugate gradient solver. The default value is determined by scipy.sparse.linalg. - tol : float + tol : float, default 1e-3 Precision of the solution. class_weight : dict or 'balanced', optional @@ -1590,14 +1590,17 @@ class RidgeCV(MultiOutputMixin, RegressorMixin, _BaseRidgeCV): Parameters ---------- - alphas : numpy array of shape [n_alphas] + alphas : numpy array of shape [n_alphas], list or tuple Array of alpha values to try. Regularization strength; must be a positive float. Regularization improves the conditioning of the problem and reduces the variance of the estimates. Larger values specify stronger regularization. Alpha corresponds to ``C^-1`` in other linear models such as LogisticRegression or LinearSVC. + Default value is (0.1, 1.0, 10.0) If using generalized cross-validation, alphas must be positive. + Note: the `alphas` feature will be of `np.ndarray` type even if the + constructor parameter was a list or a tuple. fit_intercept : bool, default True Whether to calculate the intercept for this model. If set @@ -1704,15 +1707,18 @@ class RidgeClassifierCV(LinearClassifierMixin, _BaseRidgeCV): Parameters ---------- - alphas : numpy array of shape [n_alphas] + alphas : numpy array of shape [n_alphas], list or tuple Array of alpha values to try. Regularization strength; must be a positive float. Regularization improves the conditioning of the problem and reduces the variance of the estimates. Larger values specify stronger regularization. Alpha corresponds to ``C^-1`` in other linear models such as LogisticRegression or LinearSVC. + Default value is (0.1, 1.0, 10.0) + Note: the `alphas` feature will be of `np.ndarray` type even if the + constructor parameter was a list or a tuple. - fit_intercept : boolean + fit_intercept : boolean, default True Whether to calculate the intercept for this model. If set to false, no intercept will be used in calculations (i.e. data is expected to be centered). From 59496d9509d8b4109b46bb218f3be4adb6132784 Mon Sep 17 00:00:00 2001 From: Alex Itkes <38556752+alexitkes@users.noreply.github.com> Date: Tue, 23 Jul 2019 23:41:33 +0300 Subject: [PATCH 02/15] Update ridge.py boolean -> bool --- sklearn/linear_model/ridge.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sklearn/linear_model/ridge.py b/sklearn/linear_model/ridge.py index aaf174dd01234..2b877f7d1a8bb 100644 --- a/sklearn/linear_model/ridge.py +++ b/sklearn/linear_model/ridge.py @@ -778,7 +778,7 @@ class RidgeClassifier(LinearClassifierMixin, _BaseRidge): Alpha corresponds to ``C^-1`` in other linear models such as LogisticRegression or LinearSVC. - fit_intercept : boolean, default True + fit_intercept : bool, default True Whether to calculate the intercept for this model. If set to false, no intercept will be used in calculations (e.g. data is expected to be already centered). @@ -1718,7 +1718,7 @@ class RidgeClassifierCV(LinearClassifierMixin, _BaseRidgeCV): Note: the `alphas` feature will be of `np.ndarray` type even if the constructor parameter was a list or a tuple. - fit_intercept : boolean, default True + fit_intercept : bool, default True Whether to calculate the intercept for this model. If set to false, no intercept will be used in calculations (i.e. data is expected to be centered). From 404b7bb5d9a5fa0cb19216a68ea374d98ff72db7 Mon Sep 17 00:00:00 2001 From: Alex Itkes <38556752+alexitkes@users.noreply.github.com> Date: Wed, 24 Jul 2019 11:36:11 +0300 Subject: [PATCH 03/15] Update ridge.py Remove unnecessary notes about iterable being converted to Numpy array --- sklearn/linear_model/ridge.py | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/sklearn/linear_model/ridge.py b/sklearn/linear_model/ridge.py index 2b877f7d1a8bb..1ac20dc92e04c 100644 --- a/sklearn/linear_model/ridge.py +++ b/sklearn/linear_model/ridge.py @@ -1590,17 +1590,14 @@ class RidgeCV(MultiOutputMixin, RegressorMixin, _BaseRidgeCV): Parameters ---------- - alphas : numpy array of shape [n_alphas], list or tuple + alphas : numpy array of shape [n_alphas], default (0.1, 1.0, 10.0) Array of alpha values to try. Regularization strength; must be a positive float. Regularization improves the conditioning of the problem and reduces the variance of the estimates. Larger values specify stronger regularization. Alpha corresponds to ``C^-1`` in other linear models such as LogisticRegression or LinearSVC. - Default value is (0.1, 1.0, 10.0) If using generalized cross-validation, alphas must be positive. - Note: the `alphas` feature will be of `np.ndarray` type even if the - constructor parameter was a list or a tuple. fit_intercept : bool, default True Whether to calculate the intercept for this model. If set @@ -1707,16 +1704,13 @@ class RidgeClassifierCV(LinearClassifierMixin, _BaseRidgeCV): Parameters ---------- - alphas : numpy array of shape [n_alphas], list or tuple + alphas : numpy array of shape [n_alphas], default (0.1, 1.0, 10.0) Array of alpha values to try. Regularization strength; must be a positive float. Regularization improves the conditioning of the problem and reduces the variance of the estimates. Larger values specify stronger regularization. Alpha corresponds to ``C^-1`` in other linear models such as LogisticRegression or LinearSVC. - Default value is (0.1, 1.0, 10.0) - Note: the `alphas` feature will be of `np.ndarray` type even if the - constructor parameter was a list or a tuple. fit_intercept : bool, default True Whether to calculate the intercept for this model. If set From fbb41b09f49b757e11c475dca4692d4fa21f58d1 Mon Sep 17 00:00:00 2001 From: Alex Itkes <38556752+alexitkes@users.noreply.github.com> Date: Wed, 24 Jul 2019 14:27:48 +0300 Subject: [PATCH 04/15] Update ridge.py Document the float/array parameters that are set to None by default. --- sklearn/linear_model/ridge.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sklearn/linear_model/ridge.py b/sklearn/linear_model/ridge.py index 1ac20dc92e04c..8167441b48db5 100644 --- a/sklearn/linear_model/ridge.py +++ b/sklearn/linear_model/ridge.py @@ -262,7 +262,7 @@ def ridge_regression(X, y, alpha, sample_weight=None, solver='auto', assumed to be specific to the targets. Hence they must correspond in number. - sample_weight : float or numpy array of shape [n_samples] + sample_weight : float or numpy array of shape [n_samples], default None Individual weights for each sample. If sample_weight is not None and solver='auto', the solver will be set to 'cholesky'. @@ -909,7 +909,7 @@ def fit(self, X, y, sample_weight=None): y : array-like of shape (n_samples,) Target values - sample_weight : float or numpy array of shape (n_samples,) + sample_weight : float or numpy array of shape (n_samples,), default None Sample weight. .. versionadded:: 0.17 @@ -1823,7 +1823,7 @@ def fit(self, X, y, sample_weight=None): y : array-like, shape (n_samples,) Target values. Will be cast to X's dtype if necessary - sample_weight : float or numpy array of shape (n_samples,) + sample_weight : float or numpy array of shape (n_samples,), default None Sample weight. Returns From e6a05faccf39ab8e4c9af5a7de2da61be4ab30f7 Mon Sep 17 00:00:00 2001 From: Alex Itkes <38556752+alexitkes@users.noreply.github.com> Date: Wed, 24 Jul 2019 14:33:27 +0300 Subject: [PATCH 05/15] Update ridge.py Make too long lines shorter. --- sklearn/linear_model/ridge.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sklearn/linear_model/ridge.py b/sklearn/linear_model/ridge.py index 8167441b48db5..82486a037e1fc 100644 --- a/sklearn/linear_model/ridge.py +++ b/sklearn/linear_model/ridge.py @@ -909,7 +909,7 @@ def fit(self, X, y, sample_weight=None): y : array-like of shape (n_samples,) Target values - sample_weight : float or numpy array of shape (n_samples,), default None + sample_weight : {float, numpy array}, shape (n_samples), default None Sample weight. .. versionadded:: 0.17 @@ -1823,7 +1823,7 @@ def fit(self, X, y, sample_weight=None): y : array-like, shape (n_samples,) Target values. Will be cast to X's dtype if necessary - sample_weight : float or numpy array of shape (n_samples,), default None + sample_weight : {float, numpy array}, shape (n_samples), default None Sample weight. Returns From c098900402dd4883ca86cd017303b5127505178f Mon Sep 17 00:00:00 2001 From: Alex Itkes <38556752+alexitkes@users.noreply.github.com> Date: Fri, 26 Jul 2019 20:33:03 +0300 Subject: [PATCH 06/15] Update ridge.py `default None` -> `default=None` --- sklearn/linear_model/ridge.py | 54 +++++++++++++++++------------------ 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/sklearn/linear_model/ridge.py b/sklearn/linear_model/ridge.py index 82486a037e1fc..aa39a05ad174f 100644 --- a/sklearn/linear_model/ridge.py +++ b/sklearn/linear_model/ridge.py @@ -262,7 +262,7 @@ def ridge_regression(X, y, alpha, sample_weight=None, solver='auto', assumed to be specific to the targets. Hence they must correspond in number. - sample_weight : float or numpy array of shape [n_samples], default None + sample_weight : float or numpy array of shape [n_samples], default=None Individual weights for each sample. If sample_weight is not None and solver='auto', the solver will be set to 'cholesky'. @@ -314,10 +314,10 @@ def ridge_regression(X, y, alpha, sample_weight=None, solver='auto', by scipy.sparse.linalg. For 'sag' and saga solver, the default value is 1000. - tol : float, default 1e-3 + tol : float, default=1e-3 Precision of the solution. - verbose : int, default 0 + verbose : int, default=0 Verbosity level. Setting verbose > 0 will display additional information depending on the solver used. @@ -328,13 +328,13 @@ def ridge_regression(X, y, alpha, sample_weight=None, solver='auto', generator; If None, the random number generator is the RandomState instance used by `np.random`. Used when ``solver`` == 'sag'. - return_n_iter : boolean, default False + return_n_iter : boolean, default=False If True, the method also returns `n_iter`, the actual number of iteration performed by the solver. .. versionadded:: 0.17 - return_intercept : boolean, default False + return_intercept : boolean, default=False If True and if X is sparse, the method also returns the intercept, and the solver is automatically changed to 'sag'. This is only a temporary fix for fitting the intercept with sparse data. For dense @@ -342,7 +342,7 @@ def ridge_regression(X, y, alpha, sample_weight=None, solver='auto', .. versionadded:: 0.17 - check_input : boolean, default True + check_input : boolean, default=True If False, the input arrays X and y will not be checked. .. versionadded:: 0.21 @@ -619,7 +619,7 @@ class Ridge(MultiOutputMixin, RegressorMixin, _BaseRidge): Parameters ---------- - alpha : {float, array-like}, shape (n_targets), default 1.0 + alpha : {float, array-like}, shape (n_targets), default=1.0 Regularization strength; must be a positive float. Regularization improves the conditioning of the problem and reduces the variance of the estimates. Larger values specify stronger regularization. @@ -628,12 +628,12 @@ class Ridge(MultiOutputMixin, RegressorMixin, _BaseRidge): assumed to be specific to the targets. Hence they must correspond in number. - fit_intercept : bool, default True + fit_intercept : bool, default=True Whether to calculate the intercept for this model. If set to false, no intercept will be used in calculations (i.e. data is expected to be centered). - normalize : boolean, optional, default False + normalize : boolean, optional, default=False This parameter is ignored when ``fit_intercept`` is set to False. If True, the regressors X will be normalized before regression by subtracting the mean and dividing by the l2-norm. @@ -641,7 +641,7 @@ class Ridge(MultiOutputMixin, RegressorMixin, _BaseRidge): :class:`sklearn.preprocessing.StandardScaler` before calling ``fit`` on an estimator with ``normalize=False``. - copy_X : boolean, optional, default True + copy_X : boolean, optional, default=True If True, X will be copied; else, it may be overwritten. max_iter : int, optional @@ -649,7 +649,7 @@ class Ridge(MultiOutputMixin, RegressorMixin, _BaseRidge): For 'sparse_cg' and 'lsqr' solvers, the default value is determined by scipy.sparse.linalg. For 'sag' solver, the default value is 1000. - tol : float, default 1e-3 + tol : float, default=1e-3 Precision of the solution. solver : {'auto', 'svd', 'cholesky', 'lsqr', 'sparse_cg', 'sag', 'saga'} @@ -771,19 +771,19 @@ class RidgeClassifier(LinearClassifierMixin, _BaseRidge): Parameters ---------- - alpha : float, default 1.0 + alpha : float, default=1.0 Regularization strength; must be a positive float. Regularization improves the conditioning of the problem and reduces the variance of the estimates. Larger values specify stronger regularization. Alpha corresponds to ``C^-1`` in other linear models such as LogisticRegression or LinearSVC. - fit_intercept : bool, default True + fit_intercept : bool, default=True Whether to calculate the intercept for this model. If set to false, no intercept will be used in calculations (e.g. data is expected to be already centered). - normalize : boolean, optional, default False + normalize : boolean, optional, default=False This parameter is ignored when ``fit_intercept`` is set to False. If True, the regressors X will be normalized before regression by subtracting the mean and dividing by the l2-norm. @@ -791,14 +791,14 @@ class RidgeClassifier(LinearClassifierMixin, _BaseRidge): :class:`sklearn.preprocessing.StandardScaler` before calling ``fit`` on an estimator with ``normalize=False``. - copy_X : boolean, optional, default True + copy_X : boolean, optional, default=True If True, X will be copied; else, it may be overwritten. max_iter : int, optional Maximum number of iterations for conjugate gradient solver. The default value is determined by scipy.sparse.linalg. - tol : float, default 1e-3 + tol : float, default=1e-3 Precision of the solution. class_weight : dict or 'balanced', optional @@ -843,7 +843,7 @@ class RidgeClassifier(LinearClassifierMixin, _BaseRidge): .. versionadded:: 0.19 SAGA solver. - random_state : int, RandomState instance or None, optional, default None + random_state : int, RandomState instance or None, optional, default=None The seed of the pseudo random number generator to use when shuffling the data. If int, random_state is the seed used by the random number generator; If RandomState instance, random_state is the random number @@ -909,7 +909,7 @@ def fit(self, X, y, sample_weight=None): y : array-like of shape (n_samples,) Target values - sample_weight : {float, numpy array}, shape (n_samples), default None + sample_weight : {float, numpy array}, shape (n_samples), default=None Sample weight. .. versionadded:: 0.17 @@ -1590,7 +1590,7 @@ class RidgeCV(MultiOutputMixin, RegressorMixin, _BaseRidgeCV): Parameters ---------- - alphas : numpy array of shape [n_alphas], default (0.1, 1.0, 10.0) + alphas : numpy array of shape [n_alphas], default=(0.1, 1.0, 10.0) Array of alpha values to try. Regularization strength; must be a positive float. Regularization improves the conditioning of the problem and reduces the variance of @@ -1599,12 +1599,12 @@ class RidgeCV(MultiOutputMixin, RegressorMixin, _BaseRidgeCV): LogisticRegression or LinearSVC. If using generalized cross-validation, alphas must be positive. - fit_intercept : bool, default True + fit_intercept : bool, default=True Whether to calculate the intercept for this model. If set to false, no intercept will be used in calculations (i.e. data is expected to be centered). - normalize : boolean, optional, default False + normalize : boolean, optional, default=False This parameter is ignored when ``fit_intercept`` is set to False. If True, the regressors X will be normalized before regression by subtracting the mean and dividing by the l2-norm. @@ -1612,7 +1612,7 @@ class RidgeCV(MultiOutputMixin, RegressorMixin, _BaseRidgeCV): :class:`sklearn.preprocessing.StandardScaler` before calling ``fit`` on an estimator with ``normalize=False``. - scoring : string, callable or None, optional, default: None + scoring : string, callable or None, optional, default=None A string (see model evaluation documentation) or a scorer callable object / function with signature ``scorer(estimator, X, y)``. @@ -1704,7 +1704,7 @@ class RidgeClassifierCV(LinearClassifierMixin, _BaseRidgeCV): Parameters ---------- - alphas : numpy array of shape [n_alphas], default (0.1, 1.0, 10.0) + alphas : numpy array of shape [n_alphas], default=(0.1, 1.0, 10.0) Array of alpha values to try. Regularization strength; must be a positive float. Regularization improves the conditioning of the problem and reduces the variance of @@ -1712,12 +1712,12 @@ class RidgeClassifierCV(LinearClassifierMixin, _BaseRidgeCV): Alpha corresponds to ``C^-1`` in other linear models such as LogisticRegression or LinearSVC. - fit_intercept : bool, default True + fit_intercept : bool, default=True Whether to calculate the intercept for this model. If set to false, no intercept will be used in calculations (i.e. data is expected to be centered). - normalize : boolean, optional, default False + normalize : boolean, optional, default=False This parameter is ignored when ``fit_intercept`` is set to False. If True, the regressors X will be normalized before regression by subtracting the mean and dividing by the l2-norm. @@ -1725,7 +1725,7 @@ class RidgeClassifierCV(LinearClassifierMixin, _BaseRidgeCV): :class:`sklearn.preprocessing.StandardScaler` before calling ``fit`` on an estimator with ``normalize=False``. - scoring : string, callable or None, optional, default: None + scoring : string, callable or None, optional, default=None A string (see model evaluation documentation) or a scorer callable object / function with signature ``scorer(estimator, X, y)``. @@ -1823,7 +1823,7 @@ def fit(self, X, y, sample_weight=None): y : array-like, shape (n_samples,) Target values. Will be cast to X's dtype if necessary - sample_weight : {float, numpy array}, shape (n_samples), default None + sample_weight : {float, numpy array}, shape (n_samples), default=None Sample weight. Returns From c9cdb911d9d9800e7a48a3654c8b5b91b4646985 Mon Sep 17 00:00:00 2001 From: Alex Itkes <38556752+alexitkes@users.noreply.github.com> Date: Fri, 26 Jul 2019 22:27:39 +0300 Subject: [PATCH 07/15] Update ridge.py Replace `optional, default=...` docstrings with just `default=...`. --- sklearn/linear_model/ridge.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/sklearn/linear_model/ridge.py b/sklearn/linear_model/ridge.py index aa39a05ad174f..7ac1654c32358 100644 --- a/sklearn/linear_model/ridge.py +++ b/sklearn/linear_model/ridge.py @@ -633,7 +633,7 @@ class Ridge(MultiOutputMixin, RegressorMixin, _BaseRidge): to false, no intercept will be used in calculations (i.e. data is expected to be centered). - normalize : boolean, optional, default=False + normalize : bool, default=False This parameter is ignored when ``fit_intercept`` is set to False. If True, the regressors X will be normalized before regression by subtracting the mean and dividing by the l2-norm. @@ -641,7 +641,7 @@ class Ridge(MultiOutputMixin, RegressorMixin, _BaseRidge): :class:`sklearn.preprocessing.StandardScaler` before calling ``fit`` on an estimator with ``normalize=False``. - copy_X : boolean, optional, default=True + copy_X : bool, default=True If True, X will be copied; else, it may be overwritten. max_iter : int, optional @@ -783,7 +783,7 @@ class RidgeClassifier(LinearClassifierMixin, _BaseRidge): intercept will be used in calculations (e.g. data is expected to be already centered). - normalize : boolean, optional, default=False + normalize : bool, default=False This parameter is ignored when ``fit_intercept`` is set to False. If True, the regressors X will be normalized before regression by subtracting the mean and dividing by the l2-norm. @@ -791,7 +791,7 @@ class RidgeClassifier(LinearClassifierMixin, _BaseRidge): :class:`sklearn.preprocessing.StandardScaler` before calling ``fit`` on an estimator with ``normalize=False``. - copy_X : boolean, optional, default=True + copy_X : bool, default=True If True, X will be copied; else, it may be overwritten. max_iter : int, optional @@ -843,7 +843,7 @@ class RidgeClassifier(LinearClassifierMixin, _BaseRidge): .. versionadded:: 0.19 SAGA solver. - random_state : int, RandomState instance or None, optional, default=None + random_state : int, RandomState instance or None, default=None The seed of the pseudo random number generator to use when shuffling the data. If int, random_state is the seed used by the random number generator; If RandomState instance, random_state is the random number @@ -1604,7 +1604,7 @@ class RidgeCV(MultiOutputMixin, RegressorMixin, _BaseRidgeCV): to false, no intercept will be used in calculations (i.e. data is expected to be centered). - normalize : boolean, optional, default=False + normalize : bool, default=False This parameter is ignored when ``fit_intercept`` is set to False. If True, the regressors X will be normalized before regression by subtracting the mean and dividing by the l2-norm. @@ -1612,7 +1612,7 @@ class RidgeCV(MultiOutputMixin, RegressorMixin, _BaseRidgeCV): :class:`sklearn.preprocessing.StandardScaler` before calling ``fit`` on an estimator with ``normalize=False``. - scoring : string, callable or None, optional, default=None + scoring : string, callable or None, default=None A string (see model evaluation documentation) or a scorer callable object / function with signature ``scorer(estimator, X, y)``. @@ -1717,7 +1717,7 @@ class RidgeClassifierCV(LinearClassifierMixin, _BaseRidgeCV): to false, no intercept will be used in calculations (i.e. data is expected to be centered). - normalize : boolean, optional, default=False + normalize : bool, default=False This parameter is ignored when ``fit_intercept`` is set to False. If True, the regressors X will be normalized before regression by subtracting the mean and dividing by the l2-norm. @@ -1725,7 +1725,7 @@ class RidgeClassifierCV(LinearClassifierMixin, _BaseRidgeCV): :class:`sklearn.preprocessing.StandardScaler` before calling ``fit`` on an estimator with ``normalize=False``. - scoring : string, callable or None, optional, default=None + scoring : string, callable or None, default=None A string (see model evaluation documentation) or a scorer callable object / function with signature ``scorer(estimator, X, y)``. From fcbe53bc9c01e45926c941b5c20d22986c2e2b3f Mon Sep 17 00:00:00 2001 From: Alex Itkes <38556752+alexitkes@users.noreply.github.com> Date: Fri, 26 Jul 2019 22:32:44 +0300 Subject: [PATCH 08/15] Update ridge.py boolean -> bool --- sklearn/linear_model/ridge.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sklearn/linear_model/ridge.py b/sklearn/linear_model/ridge.py index 7ac1654c32358..7b1726d67ad67 100644 --- a/sklearn/linear_model/ridge.py +++ b/sklearn/linear_model/ridge.py @@ -328,13 +328,13 @@ def ridge_regression(X, y, alpha, sample_weight=None, solver='auto', generator; If None, the random number generator is the RandomState instance used by `np.random`. Used when ``solver`` == 'sag'. - return_n_iter : boolean, default=False + return_n_iter : bool, default=False If True, the method also returns `n_iter`, the actual number of iteration performed by the solver. .. versionadded:: 0.17 - return_intercept : boolean, default=False + return_intercept : bool, default=False If True and if X is sparse, the method also returns the intercept, and the solver is automatically changed to 'sag'. This is only a temporary fix for fitting the intercept with sparse data. For dense @@ -342,7 +342,7 @@ def ridge_regression(X, y, alpha, sample_weight=None, solver='auto', .. versionadded:: 0.17 - check_input : boolean, default=True + check_input : bool, default=True If False, the input arrays X and y will not be checked. .. versionadded:: 0.21 From ebafca09fae30fe521285b50e0ebc23446cbfcd0 Mon Sep 17 00:00:00 2001 From: Alex Itkes <38556752+alexitkes@users.noreply.github.com> Date: Tue, 8 Oct 2019 16:47:35 +0300 Subject: [PATCH 09/15] Update sklearn/linear_model/ridge.py Specify array shape as (n_samples,) instead of [n_samples] Co-Authored-By: Roman Yurchak --- sklearn/linear_model/ridge.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sklearn/linear_model/ridge.py b/sklearn/linear_model/ridge.py index 7b1726d67ad67..7818eb2e9c971 100644 --- a/sklearn/linear_model/ridge.py +++ b/sklearn/linear_model/ridge.py @@ -262,7 +262,7 @@ def ridge_regression(X, y, alpha, sample_weight=None, solver='auto', assumed to be specific to the targets. Hence they must correspond in number. - sample_weight : float or numpy array of shape [n_samples], default=None + sample_weight : float or numpy array of shape (n_samples,), default=None Individual weights for each sample. If sample_weight is not None and solver='auto', the solver will be set to 'cholesky'. From 05dd75495860fbcbb3106f245ab2c8628d4a0d2a Mon Sep 17 00:00:00 2001 From: Alex Itkes <38556752+alexitkes@users.noreply.github.com> Date: Tue, 8 Oct 2019 16:48:16 +0300 Subject: [PATCH 10/15] Update sklearn/linear_model/ridge.py Update parameter type description Co-Authored-By: Roman Yurchak --- sklearn/linear_model/ridge.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sklearn/linear_model/ridge.py b/sklearn/linear_model/ridge.py index 7818eb2e9c971..ec793d73e00b2 100644 --- a/sklearn/linear_model/ridge.py +++ b/sklearn/linear_model/ridge.py @@ -619,7 +619,7 @@ class Ridge(MultiOutputMixin, RegressorMixin, _BaseRidge): Parameters ---------- - alpha : {float, array-like}, shape (n_targets), default=1.0 + alpha : {float, array-like of shape (n_targets,)}, default=1.0 Regularization strength; must be a positive float. Regularization improves the conditioning of the problem and reduces the variance of the estimates. Larger values specify stronger regularization. From 898a5b288b512e35a27788d54d567ba55fc24e26 Mon Sep 17 00:00:00 2001 From: Alex Itkes <38556752+alexitkes@users.noreply.github.com> Date: Tue, 8 Oct 2019 16:48:45 +0300 Subject: [PATCH 11/15] Update sklearn/linear_model/ridge.py Update parameter type description Co-Authored-By: Roman Yurchak --- sklearn/linear_model/ridge.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sklearn/linear_model/ridge.py b/sklearn/linear_model/ridge.py index ec793d73e00b2..279728496db5d 100644 --- a/sklearn/linear_model/ridge.py +++ b/sklearn/linear_model/ridge.py @@ -909,7 +909,7 @@ def fit(self, X, y, sample_weight=None): y : array-like of shape (n_samples,) Target values - sample_weight : {float, numpy array}, shape (n_samples), default=None + sample_weight : {float, numpy array of shape (n_samples,)}, default=None Sample weight. .. versionadded:: 0.17 From 74eca4eee411069667e70445292e422e5d6436c2 Mon Sep 17 00:00:00 2001 From: Alex Itkes <38556752+alexitkes@users.noreply.github.com> Date: Tue, 8 Oct 2019 16:49:27 +0300 Subject: [PATCH 12/15] Update sklearn/linear_model/ridge.py Update array shape description in parameter documentation Co-Authored-By: Roman Yurchak --- sklearn/linear_model/ridge.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sklearn/linear_model/ridge.py b/sklearn/linear_model/ridge.py index 279728496db5d..4db1ebd4504be 100644 --- a/sklearn/linear_model/ridge.py +++ b/sklearn/linear_model/ridge.py @@ -1590,7 +1590,7 @@ class RidgeCV(MultiOutputMixin, RegressorMixin, _BaseRidgeCV): Parameters ---------- - alphas : numpy array of shape [n_alphas], default=(0.1, 1.0, 10.0) + alphas : numpy array of shape (n_alphas,), default=(0.1, 1.0, 10.0) Array of alpha values to try. Regularization strength; must be a positive float. Regularization improves the conditioning of the problem and reduces the variance of From 018acc91686af443781e8b1770e7f40ad320664d Mon Sep 17 00:00:00 2001 From: Alex Itkes <38556752+alexitkes@users.noreply.github.com> Date: Tue, 8 Oct 2019 16:50:00 +0300 Subject: [PATCH 13/15] Update sklearn/linear_model/ridge.py Update array shape description Co-Authored-By: Roman Yurchak --- sklearn/linear_model/ridge.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sklearn/linear_model/ridge.py b/sklearn/linear_model/ridge.py index 4db1ebd4504be..f924fca6daa7c 100644 --- a/sklearn/linear_model/ridge.py +++ b/sklearn/linear_model/ridge.py @@ -1704,7 +1704,7 @@ class RidgeClassifierCV(LinearClassifierMixin, _BaseRidgeCV): Parameters ---------- - alphas : numpy array of shape [n_alphas], default=(0.1, 1.0, 10.0) + alphas : numpy array of shape (n_alphas,), default=(0.1, 1.0, 10.0) Array of alpha values to try. Regularization strength; must be a positive float. Regularization improves the conditioning of the problem and reduces the variance of From f18a01e0678e7d8ded69019030f2293f56b7b637 Mon Sep 17 00:00:00 2001 From: Alex Itkes <38556752+alexitkes@users.noreply.github.com> Date: Tue, 8 Oct 2019 16:51:10 +0300 Subject: [PATCH 14/15] Update sklearn/linear_model/ridge.py Update parameter type documentation Co-Authored-By: Roman Yurchak --- sklearn/linear_model/ridge.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sklearn/linear_model/ridge.py b/sklearn/linear_model/ridge.py index f924fca6daa7c..a38241b8a6705 100644 --- a/sklearn/linear_model/ridge.py +++ b/sklearn/linear_model/ridge.py @@ -1823,7 +1823,7 @@ def fit(self, X, y, sample_weight=None): y : array-like, shape (n_samples,) Target values. Will be cast to X's dtype if necessary - sample_weight : {float, numpy array}, shape (n_samples), default=None + sample_weight : {float, numpy array of shape (n_samples,)}, default=None Sample weight. Returns From a51da4419909d733102832ffb648fca663a8c3bd Mon Sep 17 00:00:00 2001 From: Roman Yurchak Date: Tue, 8 Oct 2019 16:51:01 +0200 Subject: [PATCH 15/15] Lint --- sklearn/linear_model/ridge.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sklearn/linear_model/ridge.py b/sklearn/linear_model/ridge.py index a38241b8a6705..d47f398d770d5 100644 --- a/sklearn/linear_model/ridge.py +++ b/sklearn/linear_model/ridge.py @@ -909,7 +909,7 @@ def fit(self, X, y, sample_weight=None): y : array-like of shape (n_samples,) Target values - sample_weight : {float, numpy array of shape (n_samples,)}, default=None + sample_weight : {float, array-like of shape (n_samples,)}, default=None Sample weight. .. versionadded:: 0.17 @@ -1823,7 +1823,7 @@ def fit(self, X, y, sample_weight=None): y : array-like, shape (n_samples,) Target values. Will be cast to X's dtype if necessary - sample_weight : {float, numpy array of shape (n_samples,)}, default=None + sample_weight : {float, array-like of shape (n_samples,)}, default=None Sample weight. Returns