r""" Nonnegative matrix factorization (NMF) performed using fast hierarchical alternating least squares (HALS) [*]_. Notes ----- The NMF minimization problem is .. math:: \min_{\mathbf{W}, \mathbf{H}} ||\mathbf{X} - \mathbf{WH}||^2
(self, K, max_iter=200, tol=1e-4)
| 159 | |
| 160 | class NMF: |
| 161 | def __init__(self, K, max_iter=200, tol=1e-4): |
| 162 | r""" |
| 163 | Nonnegative matrix factorization (NMF) performed using fast |
| 164 | hierarchical alternating least squares (HALS) [*]_. |
| 165 | |
| 166 | Notes |
| 167 | ----- |
| 168 | The NMF minimization problem is |
| 169 | |
| 170 | .. math:: |
| 171 | |
| 172 | \min_{\mathbf{W}, \mathbf{H}} ||\mathbf{X} - \mathbf{WH}||^2 |
| 173 | \ \ \ \ \text{subject to } \mathbf{W}, \mathbf{H} \geq 0 |
| 174 | |
| 175 | where :math:`||\cdot||` denotes the Frobenius norm, and the notation |
| 176 | :math:`\mathbf{A} \geq 0` indicates that each element of **A** is |
| 177 | greater than or equal to 0. In the above equation, **X** is the |
| 178 | :math:`N \times M` data matrix, :math:`\mathbf{W}` and |
| 179 | :math:`\mathbf{H}` are learned factor matrices with dimensions :math:`N |
| 180 | \times K` and :math:`K \times M`, respectively. |
| 181 | |
| 182 | As with other ALS-based approaches, there is no guarantee that NMF will |
| 183 | converge to a stationary point, let alone a global minimum. As a result |
| 184 | it is generally good practice to run the algorithm multiple times with |
| 185 | different initializations, taking the outcome that achieves the lowest |
| 186 | reconstruction error. |
| 187 | |
| 188 | References |
| 189 | ---------- |
| 190 | .. [*] Cichocki, A., & Phan, A. (2009). Fast local algorithms for |
| 191 | large scale nonnegative matrix and tensor factorizations. *IEICE |
| 192 | Transactions on Fundamentals of Electronics, Communications and |
| 193 | Computer Sciences, 92(3)*, 708-721. |
| 194 | |
| 195 | Parameters |
| 196 | ---------- |
| 197 | K : int |
| 198 | The number of latent factors to include in the factor matrices **W** |
| 199 | and **H**. |
| 200 | max_iter : int |
| 201 | The maximum number of iterations to run before stopping. Default is |
| 202 | 200. |
| 203 | tol : float |
| 204 | The tolerance for the stopping condition. Default is 1e-4. |
| 205 | """ |
| 206 | self.K = K |
| 207 | self.W = None |
| 208 | self.H = None |
| 209 | self.tol = tol |
| 210 | self.max_iter = max_iter |
| 211 | |
| 212 | @property |
| 213 | def parameters(self): |
nothing calls this directly
no outgoing calls
no test coverage detected