MCPcopy Create free account
hub / github.com/ddbourgin/numpy-ml / _update_H

Method _update_H

numpy_ml/factorization/factors.py:251–260  ·  view source on GitHub ↗

Perform the fast HALS update for H

(self, X, W, H)

Source from the content-addressed store, hash-verified

249 return np.sum((X - Xhat) ** 2)
250
251 def _update_H(self, X, W, H):
252 """Perform the fast HALS update for H"""
253 eps = np.finfo(float).eps
254 XtW = X.T @ W # dim: (M, K)
255 WtW = W.T @ W # dim: (K, K)
256
257 for k in range(self.K):
258 H[k, :] += XtW[:, k] - H.T @ WtW[:, k]
259 H[k, :] = np.clip(H[k, :], eps, np.inf) # enforce nonnegativity
260 return H
261
262 def _update_W(self, X, W, H):
263 """Perform the fast HALS update for W"""

Callers 1

_fitMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected