From aba8a6ca822c2f82660c17d8dcf8ef72442693b7 Mon Sep 17 00:00:00 2001 From: frellwan Date: Tue, 21 Sep 2021 20:10:21 -0400 Subject: [PATCH 1/9] (#20308) Changed order of sections for SGDOneClassSVM Docstring --- sklearn/linear_model/_stochastic_gradient.py | 22 ++++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/sklearn/linear_model/_stochastic_gradient.py b/sklearn/linear_model/_stochastic_gradient.py index b429d8227553a..c6a9baa85a3ed 100644 --- a/sklearn/linear_model/_stochastic_gradient.py +++ b/sklearn/linear_model/_stochastic_gradient.py @@ -2059,6 +2059,17 @@ class SGDOneClassSVM(BaseSGD, OutlierMixin): .. versionadded:: 1.0 + See Also + -------- + sklearn.svm.OneClassSVM + + Notes + ----- + This estimator has a linear complexity in the number of training samples + and is thus better suited than the `sklearn.svm.OneClassSVM` + implementation for datasets with a large number of training samples (say + > 10,000). + Examples -------- >>> import numpy as np @@ -2070,17 +2081,6 @@ class SGDOneClassSVM(BaseSGD, OutlierMixin): >>> print(clf.predict([[4, 4]])) [1] - - See also - -------- - sklearn.svm.OneClassSVM - - Notes - ----- - This estimator has a linear complexity in the number of training samples - and is thus better suited than the `sklearn.svm.OneClassSVM` - implementation for datasets with a large number of training samples (say - > 10,000). """ loss_functions = {"hinge": (Hinge, 1.0)} From 0b6fa2ea9bd17e5edace6867dd921249f440b452 Mon Sep 17 00:00:00 2001 From: frellwan Date: Tue, 21 Sep 2021 20:13:41 -0400 Subject: [PATCH 2/9] (#20308) Changed parameter 'verbose' to int and added period in SGDOneClassSVM Docstring --- sklearn/linear_model/_stochastic_gradient.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sklearn/linear_model/_stochastic_gradient.py b/sklearn/linear_model/_stochastic_gradient.py index c6a9baa85a3ed..d2e70f2e15734 100644 --- a/sklearn/linear_model/_stochastic_gradient.py +++ b/sklearn/linear_model/_stochastic_gradient.py @@ -1975,8 +1975,8 @@ class SGDOneClassSVM(BaseSGD, OutlierMixin): Whether or not the training data should be shuffled after each epoch. Defaults to True. - verbose : integer, optional - The verbosity level + verbose : int, optional + The verbosity level. random_state : int, RandomState instance or None, optional (default=None) The seed of the pseudo random number generator to use when shuffling @@ -2061,7 +2061,7 @@ class SGDOneClassSVM(BaseSGD, OutlierMixin): See Also -------- - sklearn.svm.OneClassSVM + sklearn.svm.OneClassSVM : Unsupervised Outlier Detection. Notes ----- From 667667c8d3cfffed0bb755f007d43335abe5ad76 Mon Sep 17 00:00:00 2001 From: frellwan Date: Tue, 21 Sep 2021 20:14:38 -0400 Subject: [PATCH 3/9] (#20308) Changed parameter 'learning rate' to str in SGDOneClassSVM Docstring --- sklearn/linear_model/_stochastic_gradient.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sklearn/linear_model/_stochastic_gradient.py b/sklearn/linear_model/_stochastic_gradient.py index d2e70f2e15734..2c4546f70a02e 100644 --- a/sklearn/linear_model/_stochastic_gradient.py +++ b/sklearn/linear_model/_stochastic_gradient.py @@ -1985,7 +1985,7 @@ class SGDOneClassSVM(BaseSGD, OutlierMixin): generator; If None, the random number generator is the RandomState instance used by `np.random`. - learning_rate : string, optional + learning_rate : str, optional The learning rate schedule to use with `fit`. (If using `partial_fit`, learning rate must be controlled directly). From 4e6c49f6e8140cfb52561e8765a79361f7ddd5b9 Mon Sep 17 00:00:00 2001 From: frellwan Date: Tue, 21 Sep 2021 20:17:14 -0400 Subject: [PATCH 4/9] (#20308) Add description for 'Returns' section of SGDOneClassSVM.fit Docstring --- sklearn/linear_model/_stochastic_gradient.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sklearn/linear_model/_stochastic_gradient.py b/sklearn/linear_model/_stochastic_gradient.py index 2c4546f70a02e..c430c9ad75dd1 100644 --- a/sklearn/linear_model/_stochastic_gradient.py +++ b/sklearn/linear_model/_stochastic_gradient.py @@ -2398,7 +2398,8 @@ def fit(self, X, y=None, coef_init=None, offset_init=None, sample_weight=None): Returns ------- - self : returns an instance of self. + self : object + returns an instance of self. """ alpha = self.nu / 2 From dfc3fb74ec5a5f18bfdf96eff9d3f7d206d56c9a Mon Sep 17 00:00:00 2001 From: frellwan Date: Tue, 21 Sep 2021 20:21:44 -0400 Subject: [PATCH 5/9] (#20308) Add parametr 'y' and description for SGDOneClassSVM.fit Docstring --- sklearn/linear_model/_stochastic_gradient.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sklearn/linear_model/_stochastic_gradient.py b/sklearn/linear_model/_stochastic_gradient.py index c430c9ad75dd1..f829e421dc766 100644 --- a/sklearn/linear_model/_stochastic_gradient.py +++ b/sklearn/linear_model/_stochastic_gradient.py @@ -2383,6 +2383,8 @@ def fit(self, X, y=None, coef_init=None, offset_init=None, sample_weight=None): ---------- X : {array-like, sparse matrix}, shape (n_samples, n_features) Training data. + y : Ignored + Not used, present for API consistency by convention. coef_init : array, shape (n_classes, n_features) The initial coefficients to warm-start the optimization. From ab99a6fe37fd60a6be21dead7ce6038414eb4bbd Mon Sep 17 00:00:00 2001 From: frellwan Date: Tue, 21 Sep 2021 20:22:39 -0400 Subject: [PATCH 6/9] (#20308) Add description for 'Returns' section SGDOneClassSVM.fit Docstring --- sklearn/linear_model/_stochastic_gradient.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sklearn/linear_model/_stochastic_gradient.py b/sklearn/linear_model/_stochastic_gradient.py index f829e421dc766..161064c602962 100644 --- a/sklearn/linear_model/_stochastic_gradient.py +++ b/sklearn/linear_model/_stochastic_gradient.py @@ -2401,7 +2401,7 @@ def fit(self, X, y=None, coef_init=None, offset_init=None, sample_weight=None): Returns ------- self : object - returns an instance of self. + Returns an instance of self. """ alpha = self.nu / 2 From e3904544c3cb2662cc291a2b7af2e21d8f4b6b26 Mon Sep 17 00:00:00 2001 From: frellwan Date: Tue, 21 Sep 2021 20:26:28 -0400 Subject: [PATCH 7/9] (#20308) Add parameter 'y' and description for SGDOneClassSVM.partial_fit Docstring --- sklearn/linear_model/_stochastic_gradient.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sklearn/linear_model/_stochastic_gradient.py b/sklearn/linear_model/_stochastic_gradient.py index 161064c602962..b302bfe44bfbf 100644 --- a/sklearn/linear_model/_stochastic_gradient.py +++ b/sklearn/linear_model/_stochastic_gradient.py @@ -2295,6 +2295,8 @@ def partial_fit(self, X, y=None, sample_weight=None): ---------- X : {array-like, sparse matrix}, shape (n_samples, n_features) Subset of the training data. + y : Ignored + Not used, present for API consistency by convention. sample_weight : array-like, shape (n_samples,), optional Weights applied to individual samples. From 76d4108cbd9cce9a74a007901001ef190ce3475e Mon Sep 17 00:00:00 2001 From: frellwan Date: Tue, 21 Sep 2021 20:30:18 -0400 Subject: [PATCH 8/9] (#20308) Add description for 'Return' section for SGDOneClassSVM.partial_fit Docstring --- sklearn/linear_model/_stochastic_gradient.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sklearn/linear_model/_stochastic_gradient.py b/sklearn/linear_model/_stochastic_gradient.py index b302bfe44bfbf..dd86c9536abd4 100644 --- a/sklearn/linear_model/_stochastic_gradient.py +++ b/sklearn/linear_model/_stochastic_gradient.py @@ -2304,7 +2304,8 @@ def partial_fit(self, X, y=None, sample_weight=None): Returns ------- - self : returns an instance of self. + self : object + Returns a fitted instance of self. """ alpha = self.nu / 2 @@ -2403,7 +2404,7 @@ def fit(self, X, y=None, coef_init=None, offset_init=None, sample_weight=None): Returns ------- self : object - Returns an instance of self. + Returns a fitted instance of self. """ alpha = self.nu / 2 From 455d2ec22e20870f926645b38bc7d363020ea42d Mon Sep 17 00:00:00 2001 From: frellwan Date: Tue, 21 Sep 2021 20:45:27 -0400 Subject: [PATCH 9/9] (#20308) Remove SGDOneClassSVM --- maint_tools/test_docstrings.py | 1 - 1 file changed, 1 deletion(-) diff --git a/maint_tools/test_docstrings.py b/maint_tools/test_docstrings.py index e1a4dd7ca5dd6..687184d6f6500 100644 --- a/maint_tools/test_docstrings.py +++ b/maint_tools/test_docstrings.py @@ -34,7 +34,6 @@ "QuadraticDiscriminantAnalysis", "RandomizedSearchCV", "RobustScaler", - "SGDOneClassSVM", "SGDRegressor", "SelfTrainingClassifier", "SparseRandomProjection",