nmf: Perform Non-negative Matrix Factorization

View source: R/RcppExports.R

nmfR Documentation

Perform Non-negative Matrix Factorization

Description

Regularly, Non-negative Matrix Factorization (NMF) is factorizes input matrix X into low rank matrices W and H, so that X \approx WH. The objective function can be stated as \arg\min_{W\ge0,H\ge0}||X-WH||_F^2. In practice, X is usually regarded as a matrix of m features by n sample points. And the result matrix W should have the dimensionality of m \times k and H with n \times k (transposed). This function wraps the algorithms implemented in PLANC library to solve NMF problems. Algorithms includes Alternating Non-negative Least Squares with Block Principal Pivoting (ANLS-BPP), Alternating Direction Method of Multipliers (ADMM), Hierarchical Alternating Least Squares (HALS), and Multiplicative Update (MU).

Usage

nmf(
  x,
  k,
  niter = 30L,
  algo = "anlsbpp",
  nCores = 2L,
  Winit = NULL,
  Hinit = NULL
)

Arguments

x

Input matrix for factorization. Can be either dense or sparse.

k

Integer. Factor matrix rank.

niter

Integer. Maximum number of NMF interations.

algo

Algorithm to perform the factorization, choose from "anlsbpp", "admm", "hals" or "mu". See detailed sections.

nCores

The number of parallel tasks that will be spawned. Only applies to anlsbpp. Default 2

Winit

Initial left-hand factor matrix, must be of size m x k.

Hinit

Initial right-hand factor matrix, must be of size n x k.

Value

A list with the following elements:

  • W - the result left-hand factor matrix

  • H - the result right hand matrix.

  • objErr - the objective error of the factorization.

References

Ramakrishnan Kannan and et al., A High-Performance Parallel Algorithm for Nonnegative Matrix Factorization, PPoPP '16, 2016, 10.1145/2851141.2851152


RcppPlanc documentation built on April 15, 2025, 1:11 a.m.