NMFfit-class {NMF}R Documentation

Base Class for to store Nonnegative Matrix Factorisation results

Description

Base class to handle the results of general Non-negative Matrix Factorisation algorithms (NMF).

It provides a general structure and generic functions to manage the results of NMF algorithms. It contains a slot with the fitted NMF model (see slot fit) as well as data about the methods and parameters used to compute the factorization.

Details

The purpose of this class is to handle in a generic way the results of NMF algorithms. Its slot fit contains the fitted NMF model as an object of class NMF.

Other slots contains data about how the factorization has been computed, such as the algorithm and seeding method, the computation time, the final residuals, etc...

Class NMFfit acts as a wrapper class for its slot fit. It inherits from interface class NMF defined for generic NMF models. Therefore, all the methods defined by this interface can be called directly on objects of class NMFfit. The calls are simply dispatched on slot fit, i.e. the results are the same as if calling the methods directly on slot fit.

Slots

fit:
An object that inherits from class "NMF". It contains the fitted NMF model.

Note that class "NMF" is a virtual class. The default class for this slot is NMFstd, that implements the standard NMF model.

residuals:
A "numeric" vector that contains the final residuals or the residuals track between the target matrix and its NMF estimate(s). Default value is numeric().

See method residuals for details on accessor methods and main interface nmf for details on how to compute NMF with residuals tracking.

method:
A single "character" string that contains the name of the algorithm used to fit the model. Default value is ''.
seed:
A single "character" string that contains the name of the seeding method used to seed the algorithm that computed the NMF. Default value is ''. See nmf-methods for more details.
distance:
Either a single "character" string that contains the name of the built-in objective function, or a function that measures the residuals between the target matrix and its NMF estimate.
parameters:
A "list" that contains the extra parameters specific to the algorithm used to fit the model.
runtime:
Object of class "proc_time" that contains various measures of the time spent to fit the model. See system.time
options:
A "list" that contains the options used to compute the object.
extra:
A "list" that contains extra miscellaneous data set by the algorithm.

Validity checks

The validity method for class NMFfit checks

Objects from the Class

Object of class NMFfit using the standard operator new.

However, there is usually no need to directly create such an object, as interface methods nmf and seed take care of it.

Methods

Class-specific methods:

algorithm
signature(object = "NMFfit"): Access slot method.

algorithm<-
signature(object = "NMFfit", value="ANY"): Set slot method.
basis
signature(object = "NMFfit"): Extract the matrix of basis vectors from the fitted NMF model. It returns basis(fit(object)).

Note that this method is part of the minimum interface for NMF models, as defined by class NMF. See NMF.

basis<-
signature(object = "NMFfit", value = "matrix": Sets the matrix of basis vectors of the fitted NMF model. It calls basis(fit(object), value).

Note that this method is part of the minimum interface for NMF models, as defined by class NMF. See NMF.

coef
signature(object = "NMFfit"): Extract the matrix of mixture coefficients from the fitted NMF model. It returns coef(fit(object)).

Note that this method is part of the minimum interface for NMF models, as defined by class NMF. See NMF.

coef<-
signature(object = "NMFfit", value = "matrix": Sets the matrix of mixture coefficients of the fitted NMF model. It calls coef(fit(object), value).

Note that this method is part of the minimum interface for NMF models, as defined by class NMF. See NMF.

distance
signature(target = "matrix", x = "NMFfit"): return the value of the loss function given a target matrix and a NMF fit. It calls method distance on slot fit. If a distance method is NOT supplied in argument method, it uses the objective function from slot objective.
errorPlot
signature(x = "NMFfit"): plot the residuals track of the run that computed object x. See function nmf for details on how to enable residuals tracking.
fitted
signature(object = "NMFfit"): compute the estimated target matrix according to the NMF model stored in slot fit. It actually dispatches the call to slot fit, returning fitted(fit(object)).

Note that this method is part of the minimum interface for NMF models, as defined by class NMF. See NMF.

extra
signature(object = "NMFfit"): Access slot extra.
fit
signature(object = "NMFfit"): return the NMF object stored in slot fit.
fit<-
signature(object = "NMFfit", value = "NMF"): set the value of the NMF object stored in slot fit.
objective
signature(object = "NMF"): return slot distance or compute the objective value if a target is passed in argument x.
objective<-
signature(object = "NMF", value = "character"): sets slot distance to a built-in distance metric identified by a character string.
objective<-
signature(object = "NMF", value = "function"): sets slot distance to a custom function. The function should return a single positive numeric and must take the target (a matrix) as its first parameter, and an object that inherits from class NMF as its second parameter. Extra parameters are passed.
residuals
signature(object = "NMFfit"): Access slot residuals. See function residuals for details on extra parameters.
residuals<-
signature(object = "NMFfit", value="numeric"): Set slot residuals to value value.
runtime
signature(object = "NMF"): return the time spent to fit NMF model object. The time is computed using base function system.time which returns object of class proc_time.
seeding
signature(object = "NMF"): returns the seeding method used to seed the algorithm that fitted NMF model object. See section nmf-methods.
seeding<-
signature(object = "NMF"): sets the seeding method used to seed the algorithm that fitted NMF model object.
show
signature(object = "NMF"): standard generic show method for objects of class NMF.
summary
signature(x = "NMF"): standard generic summary method for objects of class NMF. It returns a numeric vector that contains the summary of the fitted NMF model (slot fit), plus the computation time and the final residuals.

Class NMFfit inherits from all the methods defined on class NMF to manipulate and interpret NMF models. For those methods, class NMFfit act as a wrapper class, dispatching the calls to slot fit. Some useful methods are: dim, nbasis, predict, sparseness. See NMF for more details.

Author(s)

Renaud Gaujoux renaud@cbio.uct.ac.za

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 default NMF algorithm on a random matrix
n <- 50; r <- 3; p <- 20
V <- matrix(runif(n*p), n, p)  
res <- nmf(V, r)                                                        

# result class is NMFfit
class(res)

# show result
res

# compute summary measures
summary(res)


[Package NMF version 0.2.4 Index]