From 7ceed3fdfe909342a91a9ccdc07f17443b720c26 Mon Sep 17 00:00:00 2001 From: reshamas Date: Wed, 14 Jul 2021 21:32:55 -0400 Subject: [PATCH 01/13] fixed typo (in --> is) --- maint_tools/test_docstrings.py | 4 ++-- sklearn/neural_network/_rbm.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/maint_tools/test_docstrings.py b/maint_tools/test_docstrings.py index 8734cef219bb2..3c28d328981eb 100644 --- a/maint_tools/test_docstrings.py +++ b/maint_tools/test_docstrings.py @@ -12,7 +12,7 @@ "AdditiveChi2Sampler", "AffinityPropagation", "AgglomerativeClustering", - "BernoulliRBM", + #"BernoulliRBM", "Birch", "CCA", "CalibratedClassifierCV", @@ -136,7 +136,7 @@ "SelectPercentile", "SelfTrainingClassifier", "SequentialFeatureSelector", - "ShrunkCovariance", + #"ShrunkCovariance", "SimpleImputer", "SkewedChi2Sampler", "SparseCoder", diff --git a/sklearn/neural_network/_rbm.py b/sklearn/neural_network/_rbm.py index 3d8647e3960f6..f95fba574c591 100644 --- a/sklearn/neural_network/_rbm.py +++ b/sklearn/neural_network/_rbm.py @@ -77,7 +77,7 @@ class BernoulliRBM(TransformerMixin, BaseEstimator): Biases of the visible units. components_ : array-like of shape (n_components, n_features) - Weight matrix, where n_features in the number of + Weight matrix, where n_features is the number of visible units and n_components is the number of hidden units. h_samples_ : array-like of shape (batch_size, n_components) From 5d428491c77bc35fce712bccd4ea7e72ad1a3a95 Mon Sep 17 00:00:00 2001 From: reshamas Date: Wed, 14 Jul 2021 22:57:39 -0400 Subject: [PATCH 02/13] fixed typos; reduced length of description --- sklearn/neural_network/_rbm.py | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/sklearn/neural_network/_rbm.py b/sklearn/neural_network/_rbm.py index f95fba574c591..5eb21bc26ade7 100644 --- a/sklearn/neural_network/_rbm.py +++ b/sklearn/neural_network/_rbm.py @@ -82,7 +82,7 @@ class BernoulliRBM(TransformerMixin, BaseEstimator): h_samples_ : array-like of shape (batch_size, n_components) Hidden Activation sampled from the model distribution, - where batch_size in the number of examples per minibatch and + where batch_size is the number of examples per minibatch and n_components is the number of hidden units. n_features_in_ : int @@ -90,15 +90,10 @@ class BernoulliRBM(TransformerMixin, BaseEstimator): .. versionadded:: 0.24 - Examples + See Also -------- - >>> import numpy as np - >>> from sklearn.neural_network import BernoulliRBM - >>> X = np.array([[0, 0, 0], [0, 1, 1], [1, 0, 1], [1, 1, 1]]) - >>> model = BernoulliRBM(n_components=2) - >>> model.fit(X) - BernoulliRBM(n_components=2) + gibbs: Gibbs sampling step. References ---------- @@ -110,6 +105,16 @@ class BernoulliRBM(TransformerMixin, BaseEstimator): [2] Tieleman, T. Training Restricted Boltzmann Machines using Approximations to the Likelihood Gradient. International Conference on Machine Learning (ICML) 2008 + + Examples + -------- + + >>> import numpy as np + >>> from sklearn.neural_network import BernoulliRBM + >>> X = np.array([[0, 0, 0], [0, 1, 1], [1, 0, 1], [1, 1, 1]]) + >>> model = BernoulliRBM(n_components=2) + >>> model.fit(X) + BernoulliRBM(n_components=2) """ def __init__( @@ -245,14 +250,15 @@ def gibbs(self, v): return v_ def partial_fit(self, X, y=None): - """Fit the model to the data X which should contain a partial - segment of the data. + """Fit the model to the partial segment of the data X. Parameters ---------- X : ndarray of shape (n_samples, n_features) Training data. + y : self + Returns ------- self : BernoulliRBM @@ -357,6 +363,8 @@ def fit(self, X, y=None): X : {array-like, sparse matrix} of shape (n_samples, n_features) Training data. + y : self + Returns ------- self : BernoulliRBM From d56f723d848dfeaea46bcff5112dffeb61a7767b Mon Sep 17 00:00:00 2001 From: reshamas Date: Wed, 14 Jul 2021 23:19:13 -0400 Subject: [PATCH 03/13] added description for y --- sklearn/neural_network/_rbm.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/sklearn/neural_network/_rbm.py b/sklearn/neural_network/_rbm.py index 5eb21bc26ade7..9ccc7e4ffb443 100644 --- a/sklearn/neural_network/_rbm.py +++ b/sklearn/neural_network/_rbm.py @@ -257,7 +257,9 @@ def partial_fit(self, X, y=None): X : ndarray of shape (n_samples, n_features) Training data. - y : self + y : Array-like of shape (n_samples,) or (n_samples, n_outputs), + default=None + Target values (None for unsupervised transformations). Returns ------- @@ -363,7 +365,9 @@ def fit(self, X, y=None): X : {array-like, sparse matrix} of shape (n_samples, n_features) Training data. - y : self + y : Array-like of shape (n_samples,) or (n_samples, n_outputs), + default=None + Target values (None for unsupervised transformations). Returns ------- From 7b45c223f2cb44ede7c4302104a8191ae5236271 Mon Sep 17 00:00:00 2001 From: reshamas Date: Wed, 14 Jul 2021 23:23:55 -0400 Subject: [PATCH 04/13] added description for y --- sklearn/neural_network/_rbm.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/sklearn/neural_network/_rbm.py b/sklearn/neural_network/_rbm.py index 9ccc7e4ffb443..91669248debcc 100644 --- a/sklearn/neural_network/_rbm.py +++ b/sklearn/neural_network/_rbm.py @@ -257,8 +257,7 @@ def partial_fit(self, X, y=None): X : ndarray of shape (n_samples, n_features) Training data. - y : Array-like of shape (n_samples,) or (n_samples, n_outputs), - default=None + y : Array-like of shape (n_samples,) or (n_samples, n_outputs), default=None Target values (None for unsupervised transformations). Returns @@ -365,8 +364,7 @@ def fit(self, X, y=None): X : {array-like, sparse matrix} of shape (n_samples, n_features) Training data. - y : Array-like of shape (n_samples,) or (n_samples, n_outputs), - default=None + y : Array-like of shape (n_samples,) or (n_samples, n_outputs), default=None Target values (None for unsupervised transformations). Returns From f278d8777b6309f41bf0544f1e937ecd0b1f793a Mon Sep 17 00:00:00 2001 From: reshamas Date: Wed, 14 Jul 2021 23:30:01 -0400 Subject: [PATCH 05/13] remove BernoulliRBM from test_docstrings.py; fix commenting error --- maint_tools/test_docstrings.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/maint_tools/test_docstrings.py b/maint_tools/test_docstrings.py index 3c28d328981eb..7b60233df7146 100644 --- a/maint_tools/test_docstrings.py +++ b/maint_tools/test_docstrings.py @@ -12,7 +12,6 @@ "AdditiveChi2Sampler", "AffinityPropagation", "AgglomerativeClustering", - #"BernoulliRBM", "Birch", "CCA", "CalibratedClassifierCV", @@ -136,7 +135,7 @@ "SelectPercentile", "SelfTrainingClassifier", "SequentialFeatureSelector", - #"ShrunkCovariance", + "ShrunkCovariance", "SimpleImputer", "SkewedChi2Sampler", "SparseCoder", From 2d9544c09f5506676162c856186f4dcb4fcf36f0 Mon Sep 17 00:00:00 2001 From: Reshama Shaikh Date: Thu, 15 Jul 2021 09:26:05 -0400 Subject: [PATCH 06/13] Update sklearn/neural_network/_rbm.py Co-authored-by: Guillaume Lemaitre --- sklearn/neural_network/_rbm.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sklearn/neural_network/_rbm.py b/sklearn/neural_network/_rbm.py index 91669248debcc..55382ab6e134e 100644 --- a/sklearn/neural_network/_rbm.py +++ b/sklearn/neural_network/_rbm.py @@ -77,7 +77,7 @@ class BernoulliRBM(TransformerMixin, BaseEstimator): Biases of the visible units. components_ : array-like of shape (n_components, n_features) - Weight matrix, where n_features is the number of + Weight matrix, where `n_features` is the number of visible units and n_components is the number of hidden units. h_samples_ : array-like of shape (batch_size, n_components) From b6cf1d421f771bc170beb32fa5ffc4e405c3f35a Mon Sep 17 00:00:00 2001 From: Reshama Shaikh Date: Thu, 15 Jul 2021 09:26:12 -0400 Subject: [PATCH 07/13] Update sklearn/neural_network/_rbm.py Co-authored-by: Guillaume Lemaitre --- sklearn/neural_network/_rbm.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sklearn/neural_network/_rbm.py b/sklearn/neural_network/_rbm.py index 55382ab6e134e..2d8343a5783c8 100644 --- a/sklearn/neural_network/_rbm.py +++ b/sklearn/neural_network/_rbm.py @@ -82,7 +82,7 @@ class BernoulliRBM(TransformerMixin, BaseEstimator): h_samples_ : array-like of shape (batch_size, n_components) Hidden Activation sampled from the model distribution, - where batch_size is the number of examples per minibatch and + where `batch_size` is the number of examples per minibatch and n_components is the number of hidden units. n_features_in_ : int From ba8df84b06eef2c8a37931ac53497b09002ff791 Mon Sep 17 00:00:00 2001 From: Reshama Shaikh Date: Thu, 15 Jul 2021 09:27:00 -0400 Subject: [PATCH 08/13] Update sklearn/neural_network/_rbm.py Co-authored-by: Guillaume Lemaitre --- sklearn/neural_network/_rbm.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sklearn/neural_network/_rbm.py b/sklearn/neural_network/_rbm.py index 2d8343a5783c8..0b7bed3ae9a60 100644 --- a/sklearn/neural_network/_rbm.py +++ b/sklearn/neural_network/_rbm.py @@ -78,7 +78,7 @@ class BernoulliRBM(TransformerMixin, BaseEstimator): components_ : array-like of shape (n_components, n_features) Weight matrix, where `n_features` is the number of - visible units and n_components is the number of hidden units. + visible units and `n_components` is the number of hidden units. h_samples_ : array-like of shape (batch_size, n_components) Hidden Activation sampled from the model distribution, From b6651049d022d0d30d8f0409b5f301b74baaa4d7 Mon Sep 17 00:00:00 2001 From: Reshama Shaikh Date: Thu, 15 Jul 2021 09:27:17 -0400 Subject: [PATCH 09/13] Update sklearn/neural_network/_rbm.py Co-authored-by: Guillaume Lemaitre --- sklearn/neural_network/_rbm.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sklearn/neural_network/_rbm.py b/sklearn/neural_network/_rbm.py index 0b7bed3ae9a60..9fc8e9b4c8cd9 100644 --- a/sklearn/neural_network/_rbm.py +++ b/sklearn/neural_network/_rbm.py @@ -257,7 +257,7 @@ def partial_fit(self, X, y=None): X : ndarray of shape (n_samples, n_features) Training data. - y : Array-like of shape (n_samples,) or (n_samples, n_outputs), default=None + y : array-like of shape (n_samples,) or (n_samples, n_outputs), default=None Target values (None for unsupervised transformations). Returns From c2feaa278671b4d05673e0d35ee6ed0f7a8eb66b Mon Sep 17 00:00:00 2001 From: Reshama Shaikh Date: Thu, 15 Jul 2021 09:27:25 -0400 Subject: [PATCH 10/13] Update sklearn/neural_network/_rbm.py Co-authored-by: Guillaume Lemaitre --- sklearn/neural_network/_rbm.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sklearn/neural_network/_rbm.py b/sklearn/neural_network/_rbm.py index 9fc8e9b4c8cd9..42f56be9dac7b 100644 --- a/sklearn/neural_network/_rbm.py +++ b/sklearn/neural_network/_rbm.py @@ -364,7 +364,7 @@ def fit(self, X, y=None): X : {array-like, sparse matrix} of shape (n_samples, n_features) Training data. - y : Array-like of shape (n_samples,) or (n_samples, n_outputs), default=None + y : array-like of shape (n_samples,) or (n_samples, n_outputs), default=None Target values (None for unsupervised transformations). Returns From 4c17c1ed3b2945ed668f75a985e7f8c3872ae12f Mon Sep 17 00:00:00 2001 From: Reshama Shaikh Date: Thu, 15 Jul 2021 09:27:41 -0400 Subject: [PATCH 11/13] Update sklearn/neural_network/_rbm.py Co-authored-by: Guillaume Lemaitre --- sklearn/neural_network/_rbm.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sklearn/neural_network/_rbm.py b/sklearn/neural_network/_rbm.py index 42f56be9dac7b..14910ab9788ec 100644 --- a/sklearn/neural_network/_rbm.py +++ b/sklearn/neural_network/_rbm.py @@ -83,7 +83,7 @@ class BernoulliRBM(TransformerMixin, BaseEstimator): h_samples_ : array-like of shape (batch_size, n_components) Hidden Activation sampled from the model distribution, where `batch_size` is the number of examples per minibatch and - n_components is the number of hidden units. + `n_components` is the number of hidden units. n_features_in_ : int Number of features seen during :term:`fit`. From 6075422b5602c54f6cbd864bc1d7a5d4b18f937f Mon Sep 17 00:00:00 2001 From: reshamas Date: Thu, 15 Jul 2021 09:54:17 -0400 Subject: [PATCH 12/13] added range of values for `verbose` parameter --- sklearn/neural_network/_rbm.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sklearn/neural_network/_rbm.py b/sklearn/neural_network/_rbm.py index 14910ab9788ec..03da514614a88 100644 --- a/sklearn/neural_network/_rbm.py +++ b/sklearn/neural_network/_rbm.py @@ -54,7 +54,8 @@ class BernoulliRBM(TransformerMixin, BaseEstimator): during training. verbose : int, default=0 - The verbosity level. The default, zero, means silent mode. + The verbosity level. The default, zero, means silent mode. Range + of values is [0, inf]. random_state : int, RandomState instance or None, default=None Determines random number generation for: From d8914ace145aa1c2a4f7fd48303734ca3453cce2 Mon Sep 17 00:00:00 2001 From: reshamas Date: Thu, 15 Jul 2021 14:50:27 -0400 Subject: [PATCH 13/13] commented out AdditiveChi2Sampler --- maint_tools/test_docstrings.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/maint_tools/test_docstrings.py b/maint_tools/test_docstrings.py index 7b60233df7146..2d3ea82964565 100644 --- a/maint_tools/test_docstrings.py +++ b/maint_tools/test_docstrings.py @@ -9,7 +9,7 @@ # List of modules ignored when checking for numpydoc validation. DOCSTRING_IGNORE_LIST = [ - "AdditiveChi2Sampler", + #"AdditiveChi2Sampler", "AffinityPropagation", "AgglomerativeClustering", "Birch",