Skip to contents

X ~ W H with W, H >= 0 by Lee-Seung multiplicative updates: Frobenius loss, or loss = "kl" for the Poisson log-likelihood of ESL eq 14.73 with the updates of eq 14.74 (W then H). The default start is the same deterministic LCG as the Python arm.

Usage

morie_esl_nmf(
  X,
  k,
  max_iter = 500,
  tol = 1e-10,
  seed = 13,
  loss = c("frobenius", "kl"),
  W0 = NULL,
  H0 = NULL
)

Arguments

X

Non-negative matrix.

k

Rank.

max_iter, tol

Update controls.

seed

LCG seed for the default start.

loss

"frobenius" or "kl".

W0, H0

Optional starting factors.

Value

Named list: estimate, W, H, frobenius_error, relative_error, iterations, converged, n, p, k, loss, and for "kl" kl_divergence, loglik, divergence_path.

References

Lee, D. D. & Seung, H. S. (2001). NIPS 13, 556-562.

Examples

X <- outer(1:6, 1:5, function(i, j) abs(sin(i * j / 3)) * 3 + (i + j) %% 3)
morie_esl_nmf(X, 2, loss = "kl")$kl_divergence
#> [1] 4.643192