@@ -959,11 +959,16 @@ def non_negative_factorization(
959
959
Constant matrix.
960
960
961
961
W : array-like of shape (n_samples, n_components), default=None
962
- If init='custom', it is used as initial guess for the solution.
962
+ If `init='custom'`, it is used as initial guess for the solution.
963
+ If `update_H=False`, it is initialised as an array of zeros, unless
964
+ `solver='mu'`, then it is filled with values calculated by
965
+ `np.sqrt(X.mean() / self._n_components)`.
966
+ If `None`, uses the initialisation method specified in `init`.
963
967
964
968
H : array-like of shape (n_components, n_features), default=None
965
- If init='custom', it is used as initial guess for the solution.
966
- If update_H=False, it is used as a constant, to solve for W only.
969
+ If `init='custom'`, it is used as initial guess for the solution.
970
+ If `update_H=False`, it is used as a constant, to solve for W only.
971
+ If `None`, uses the initialisation method specified in `init`.
967
972
968
973
n_components : int, default=None
969
974
Number of components, if n_components is not set all features
@@ -984,8 +989,8 @@ def non_negative_factorization(
984
989
- 'nndsvdar': NNDSVD with zeros filled with small random values
985
990
(generally faster, less accurate alternative to NNDSVDa
986
991
for when sparsity is not desired)
987
- - 'custom': use custom matrices W and H if `update_H=True`. If
988
- `update_H=False`, then only custom matrix H is used.
992
+ - 'custom': If `update_H=True`, use custom matrices W and H which must both
993
+ be provided. If `update_H=False`, then only custom matrix H is used.
989
994
990
995
.. versionchanged:: 0.23
991
996
The default value of `init` changed from 'random' to None in 0.23.
@@ -1327,7 +1332,7 @@ class NMF(_BaseNMF):
1327
1332
otherwise random.
1328
1333
1329
1334
- `'random'`: non-negative random matrices, scaled with:
1330
- sqrt(X.mean() / n_components)
1335
+ ` sqrt(X.mean() / n_components)`
1331
1336
1332
1337
- `'nndsvd'`: Nonnegative Double Singular Value Decomposition (NNDSVD)
1333
1338
initialization (better for sparseness)
@@ -1339,7 +1344,7 @@ class NMF(_BaseNMF):
1339
1344
(generally faster, less accurate alternative to NNDSVDa
1340
1345
for when sparsity is not desired)
1341
1346
1342
- - `'custom'`: use custom matrices W and H
1347
+ - `'custom'`: Use custom matrices `W` and `H` which must both be provided.
1343
1348
1344
1349
.. versionchanged:: 1.1
1345
1350
When `init=None` and n_components is less than n_samples and n_features
@@ -1545,11 +1550,13 @@ def fit_transform(self, X, y=None, W=None, H=None):
1545
1550
y : Ignored
1546
1551
Not used, present for API consistency by convention.
1547
1552
1548
- W : array-like of shape (n_samples, n_components)
1549
- If init='custom', it is used as initial guess for the solution.
1553
+ W : array-like of shape (n_samples, n_components), default=None
1554
+ If `init='custom'`, it is used as initial guess for the solution.
1555
+ If `None`, uses the initialisation method specified in `init`.
1550
1556
1551
- H : array-like of shape (n_components, n_features)
1552
- If init='custom', it is used as initial guess for the solution.
1557
+ H : array-like of shape (n_components, n_features), default=None
1558
+ If `init='custom'`, it is used as initial guess for the solution.
1559
+ If `None`, uses the initialisation method specified in `init`.
1553
1560
1554
1561
Returns
1555
1562
-------
@@ -1585,12 +1592,17 @@ def _fit_transform(self, X, y=None, W=None, H=None, update_H=True):
1585
1592
1586
1593
y : Ignored
1587
1594
1588
- W : array-like of shape (n_samples, n_components)
1589
- If init='custom', it is used as initial guess for the solution.
1595
+ W : array-like of shape (n_samples, n_components), default=None
1596
+ If `init='custom'`, it is used as initial guess for the solution.
1597
+ If `update_H=False`, it is initialised as an array of zeros, unless
1598
+ `solver='mu'`, then it is filled with values calculated by
1599
+ `np.sqrt(X.mean() / self._n_components)`.
1600
+ If `None`, uses the initialisation method specified in `init`.
1590
1601
1591
- H : array-like of shape (n_components, n_features)
1592
- If init='custom', it is used as initial guess for the solution.
1593
- If update_H=False, it is used as a constant, to solve for W only.
1602
+ H : array-like of shape (n_components, n_features), default=None
1603
+ If `init='custom'`, it is used as initial guess for the solution.
1604
+ If `update_H=False`, it is used as a constant, to solve for W only.
1605
+ If `None`, uses the initialisation method specified in `init`.
1594
1606
1595
1607
update_H : bool, default=True
1596
1608
If True, both W and H will be estimated from initial guesses,
@@ -1765,7 +1777,7 @@ class MiniBatchNMF(_BaseNMF):
1765
1777
(generally faster, less accurate alternative to NNDSVDa
1766
1778
for when sparsity is not desired).
1767
1779
1768
- - `'custom'`: use custom matrices `W` and `H`
1780
+ - `'custom'`: Use custom matrices `W` and `H` which must both be provided.
1769
1781
1770
1782
batch_size : int, default=1024
1771
1783
Number of samples in each mini-batch. Large batch sizes
@@ -2124,9 +2136,11 @@ def fit_transform(self, X, y=None, W=None, H=None):
2124
2136
2125
2137
W : array-like of shape (n_samples, n_components), default=None
2126
2138
If `init='custom'`, it is used as initial guess for the solution.
2139
+ If `None`, uses the initialisation method specified in `init`.
2127
2140
2128
2141
H : array-like of shape (n_components, n_features), default=None
2129
2142
If `init='custom'`, it is used as initial guess for the solution.
2143
+ If `None`, uses the initialisation method specified in `init`.
2130
2144
2131
2145
Returns
2132
2146
-------
@@ -2162,11 +2176,16 @@ def _fit_transform(self, X, W=None, H=None, update_H=True):
2162
2176
Data matrix to be decomposed.
2163
2177
2164
2178
W : array-like of shape (n_samples, n_components), default=None
2165
- If init='custom', it is used as initial guess for the solution.
2179
+ If `init='custom'`, it is used as initial guess for the solution.
2180
+ If `update_H=False`, it is initialised as an array of zeros, unless
2181
+ `solver='mu'`, then it is filled with values calculated by
2182
+ `np.sqrt(X.mean() / self._n_components)`.
2183
+ If `None`, uses the initialisation method specified in `init`.
2166
2184
2167
2185
H : array-like of shape (n_components, n_features), default=None
2168
- If init='custom', it is used as initial guess for the solution.
2169
- If update_H=False, it is used as a constant, to solve for W only.
2186
+ If `init='custom'`, it is used as initial guess for the solution.
2187
+ If `update_H=False`, it is used as a constant, to solve for W only.
2188
+ If `None`, uses the initialisation method specified in `init`.
2170
2189
2171
2190
update_H : bool, default=True
2172
2191
If True, both W and H will be estimated from initial guesses,
0 commit comments