Skip to content

DOC Ensures that BernoulliRBM passes numpydoc validation #20533

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 16 commits into from
Sep 1, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion maint_tools/test_docstrings.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

# List of modules ignored when checking for numpydoc validation.
DOCSTRING_IGNORE_LIST = [
"BernoulliRBM",
"Birch",
"FeatureHasher",
"FeatureUnion",
Expand Down
43 changes: 28 additions & 15 deletions sklearn/neural_network/_rbm.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,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:
Expand All @@ -76,13 +77,13 @@ 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
visible units and n_components is the number of hidden units.
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)
Hidden Activation sampled from the model distribution,
where batch_size in the number of examples per minibatch and
n_components is the number of hidden units.
where `batch_size` is the number of examples per minibatch and
`n_components` is the number of hidden units.

n_features_in_ : int
Number of features seen during :term:`fit`.
Expand All @@ -95,15 +96,12 @@ class BernoulliRBM(TransformerMixin, BaseEstimator):

.. versionadded:: 1.0

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)
sklearn.neural_network.MLPRegressor : Multi-layer Perceptron regressor.
sklearn.neural_network.MLPClassifier : Multi-layer Perceptron classifier.
sklearn.decomposition.PCA : An unsupervised linear dimensionality
reduction model.

References
----------
Expand All @@ -115,6 +113,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__(
Expand Down Expand Up @@ -250,14 +258,16 @@ 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 : array-like of shape (n_samples,) or (n_samples, n_outputs), default=None
Target values (None for unsupervised transformations).

Returns
-------
self : BernoulliRBM
Expand Down Expand Up @@ -362,6 +372,9 @@ 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
Target values (None for unsupervised transformations).

Returns
-------
self : BernoulliRBM
Expand Down