Learn R Programming

NMF (version 0.5.06)

NMFstd-class: Implement of the standard NMF model

Description

Class that implements the standard model of Nonnegative Matrix Factorisation.

It provides a general structure and generic functions to manage factorizations that follow NMF standard model.

Arguments

Validity checks

The validity method for class NMF checks for compatibility of slots W and H, as those matrices must be compatible with respect to the matrix product. It also checks the relevance of the factorisation, and throws a warning when the factorisation rank is greater than the number of columns in H.

Objects from the Class

Factory method

The more convenient way of creating NMF objects is to use factory method nmfModel:

nmfModel(rank=0, target=0, model='NMFstd', ...)

It provides a unique interface to create NMF objects that can follow different NMF models, and is designed to resolve potential inconsistencies in the matrices dimensions. See nmfModel.

For example, to build a 5-rank NMF model compatible to fit a given matrix V, one calls:

nmfModel(5, V)

If the factors $W$ and $H$ are already available, they can be used to initialise the model:

nmfModel(5, V, W=w, H=h)

Standard way

Objects can still be created by calls of the usual form:

new("NMF")

new("NMF", W=w, H=h)

Details

Let $V$ be a $n \times m$ non-negative matrix and $r$ a positive integer. In its standard form (see references below), a NMF of $V$ is commonly defined as a pair of matrices $(W, H)$ such that: $$V \equiv W H,$$ where:
  • $W$and$H$are$n \times r$and$r \times m$matrices respectively with non-negative entries;
  • $\equiv$is to be understood with respect to some loss function. Common choices of loss functions are based on Frobenius norm or Kullbach-Leibler divergence.

Integer $r$ is called the factorization rank. Depending on the context of application of NMF, the columns of $W$ and $H$ take different names: [object Object],[object Object] NMF approach has been successfully applied to several fields. Package NMF was implemented trying to use names as generic as possible for objects and methods. The following terminology is used: [object Object],[object Object],[object Object],[object Object],[object Object],[object Object] However, because package NMF was primilary implemented to work with gene expression microarray data, it also provides a layer to easily and intuitively work with objects from the Bioconductor base framework. See NMF-bioc for more details.

References

Definition of Nonnegative Matrix Factorization in its modern formulation: Lee D.D. and Seung H.S. (1999). Learning the parts of objects by non-negative matrix factorization. Nature, 401, 788--791.

Historical first definition and algorithms: Paatero, P., Tapper, U. (1994). Positive matrix factorization: A non-negative factor model with optimal utilization of error estimates of data values. Environmetrics, 2, 111--126 , doi:10.1002/env.3170050203. Reference for some utility functions: Kim, H. and Park, H. (2007). Sparse non-negative matrix factorizations via alternating non-negativity-constrained least squares for microarray data analysis. Bioinformatics. Hoyer (2004). Non-negative matrix factorization with sparseness constraints. Journal of Machine Learning Research, 5, 1457-1469.

See Also

Main interface to perform NMF in nmf-methods. Method seed to set NMF objects with values suitable to start algorithms with.

Examples

Run this code
# create a completely empty NMF object (i.e. 0 features, 0 basis components, 0 samples)
new('NMFstd')

# create a NMF object based on one random matrix: the missing matrix is deduced
# Note this only works when using factory method NMF 
n <- 50; r <- 3; 
w <- matrix(runif(n*r), n, r) 
nmfModel(W=w)

# create a NMF object based on random (compatible) matrices
p <- 20
h <- matrix(runif(r*p), r, p)
nmfModel(W=w, H=h)

# create a NMF object based on incompatible matrices: generate an error
h <- matrix(runif((r+1)*p), r+1, p)
new('NMFstd', W=w, H=h)

# same thing using the factory method: dimensions are corrected and a warning 
# is thrown saying that the dimensions used are reduced 
nmfModel(W=w, H=h)

# apply default NMF algorithm to a random target matrix
V <- matrix(runif(n*p), n, p)
nmf(V, r)

Run the code above in your browser using DataLab