8000 DOC specify the meaning of W=None and H=None in sklearn.decomposition.non_negative_factorization by marenwestermann · Pull Request #25770 · scikit-learn/scikit-learn · GitHub
[go: up one dir, main page]

Skip to content

DOC specify the meaning of W=None and H=None in sklearn.decomposition.non_negative_factorization #25770

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
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
59 changes: 39 additions & 20 deletions sklearn/decomposition/_nmf.py
Original file line number Diff line number Diff line change
Expand Up @@ -959,11 +959,16 @@ def non_negative_factorization(
Constant matrix.

W : array-like of shape (n_samples, n_components), default=None
If init='custom', it is used as initial guess for the solution.
If `init='custom'`, it is used as initial guess for the solution.
If `update_H=False`, it is initialised as an array of zeros, unless
`solver='mu'`, then it is filled with values calculated by
`np.sqrt(X.mean() / self._n_components)`.
If `None`, uses the initialisation method specified in `init`.

H : array-like of shape (n_components, n_features), default=None
If init='custom', it is used as initial guess for the solution.
If update_H=False, it is used as a constant, to solve for W only.
If `init='custom'`, it is used as initial guess for the solution.
If `update_H=False`, it is used as a constant, to solve for W only.
If `None`, uses the initialisation method specified in `init`.

n_components : int, default=None
Number of components, if n_components is not set all features
Expand All @@ -984,8 +989,8 @@ def non_negative_factorization(
- 'nndsvdar': NNDSVD with zeros filled with small random values
(generally faster, less accurate alternative to NNDSVDa
for when sparsity is not desired)
- 'custom': use custom matrices W and H if `update_H=True`. If
`update_H=False`, then only custom matrix H is used.
- 'custom': If `update_H=True`, use custom matrices W and H which must both
be provided. If `update_H=False`, then only custom matrix H is used.

.. versionchanged:: 0.23
The default value of `init` changed from 'random' to None in 0.23.
Expand Down Expand Up @@ -1327,7 +1332,7 @@ class NMF(_BaseNMF):
otherwise random.

- `'random'`: non-negative random matrices, scaled with:
sqrt(X.mean() / n_components)
`sqrt(X.mean() / n_components)`

- `'nndsvd'`: Nonnegative Double Singular Value Decomposition (NNDSVD)
initialization (better for sparseness)
Expand All @@ -1339,7 +1344,7 @@ class NMF(_BaseNMF):
(generally faster, less accurate alternative to NNDSVDa
for when sparsity is not desired)

- `'custom'`: use custom matrices W and H
- `'custom'`: Use custom matrices `W` and `H` which must both be provided.

.. versionchanged:: 1.1
When `init=None` and n_components is less than n_samples and n_features
Expand Down Expand Up @@ -1545,11 +1550,13 @@ def fit_transform(self, X, y=None, W=None, H=None):
y : Ignored
Not used, present for API consistency by convention.

W : array-like of shape (n_samples, n_components)
If init='custom', it is used as initial guess for the solution.
W : array-like of shape (n_samples, n_components), default=None
If `init='custom'`, it is used as initial guess for the solution.
If `None`, uses the initialisation method specified in `init`.

H : array-like of shape (n_components, n_features)
If init='custom', it is used as initial guess for the solution.
H : array-like of shape (n_components, n_features), default=None
If `init='custom'`, it is used as initial guess for the solution.
If `None`, uses the initialisation method specified in `init`.

Returns
-------
Expand Down Expand Up @@ -1585,12 +1592,17 @@ def _fit_transform(self, X, y=None, W=None, H=None, update_H=True):

y : Ignored

W : array-like of shape (n_samples, n_components)
If init='custom', it is used as initial guess for the solution.
W : array-like of shape (n_samples, n_components), default=None
If `init='custom'`, it is used as initial guess for the solution.
If `update_H=False`, it is initialised as an array of zeros, unless
`solver='mu'`, then it is filled with values calculated by
`np.sqrt(X.mean() / self._n_components)`.
If `None`, uses the initialisation method specified in `init`.

H : array-like of shape (n_components, n_features)
If init='custom', it is used as initial guess for the solution.
If update_H=False, it is used as a constant, to solve for W only.
H : array-like of shape (n_components, n_features), default=None
If `init='custom'`, it is used as initial guess for the solution.
If `update_H=False`, it is used as a constant, to solve for W only.
If `None`, uses the initialisation method specified in `init`.

update_H : bool, default=True
If True, both W and H will be estimated from initial guesses,
Expand Down Expand Up @@ -1765,7 +1777,7 @@ class MiniBatchNMF(_BaseNMF):
(generally faster, less accurate alternative to NNDSVDa
for when sparsity is not desired).

- `'custom'`: use custom matrices `W` and `H`
- `'custom'`: Use custom matrices `W` and `H` which must both be provided.

batch_size : int, default=1024
Number of samples in each mini-batch. Large batch sizes
Expand Down Expand Up @@ -2124,9 +2136,11 @@ def fit_transform(self, X, y=None, W=None, H=None):

W : array-like of shape (n_samples, n_components), default=None
If `init='custom'`, it is used as initial guess for the solution.
If `None`, uses the initialisation method specified in `init`.

H : array-like of shape (n_components, n_features), default=None
If `init='custom'`, it is used as initial guess for the solution.
If `None`, uses the initialisation method specified in `init`.

Returns
-------
Expand Down Expand Up @@ -2162,11 +2176,16 @@ def _fit_transform(self, X, W=None, H=None, update_H=True):
Data matrix to be decomposed.

W : array-like of shape (n_samples, n_components), default=None
If init='custom', it is used as initial guess for the solution.
If `init='custom'`, it is used as initial guess for the solution.
If `update_H=False`, it is initialised as an array of zeros, unless
`solver='mu'`, then it is filled with values calculated by
`np.sqrt(X.mean() / self._n_components)`.
If `None`, uses the initialisation method specified in `init`.

H : array-like of shape (n_components, n_features), default=None
If init='custom', it is used as initial guess for the solution.
If update_H=False, it is used as a constant, to solve for W only.
If `init='custom'`, it is used as initial guess for the solution.
If `update_H=False`, it is used as a constant, to solve for W only.
If `None`, uses the initialisation method specified in `init`.

update_H : bool, default=True
If True, both W and H will be estimated from initia 4162 l guesses,
Expand Down
0