NMFfit-class {NMF} | R Documentation |
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.
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
.
fit
:"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
:"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
:"character"
string that contains the name of the algorithm used to fit
the model. Default value is ''
.seed
:"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
:"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
:"list"
that contains the extra parameters specific to the algorithm used
to fit the model. runtime
:"proc_time"
that contains
various measures of the time spent to fit the model.
See system.time
options
:"list"
that contains the options used to compute the object.extra
:"list"
that contains extra miscellaneous data set by the algorithm.
The validity method for class NMFfit
checks
fit
calling the suitable validity function on this object
of class NMF
(see NMF
for more details).
objective
that must be either a function
definition or a non-empty character string.
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.
Class-specific methods:
signature(object = "NMFfit")
: Access slot method
.signature(object = "NMFfit", value="ANY")
: Set slot method
.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
.
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
.
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
.
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
.
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
.
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.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
.
signature(object = "NMFfit")
: Access slot extra
. signature(object = "NMFfit")
: return the NMF
object
stored in slot fit
.
signature(object = "NMFfit", value = "NMF")
:
set the value of the NMF
object stored in slot fit
.
signature(object = "NMF")
: return slot distance
or compute the objective value if a target is passed in argument x
.signature(object = "NMF", value = "character")
:
sets slot distance
to a built-in distance metric identified by a
character
string.
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.
signature(object = "NMFfit")
: Access slot residuals
.
See function residuals
for details
on extra parameters.
signature(object = "NMFfit", value="numeric")
:
Set slot residuals
to value value
.
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
. signature(object = "NMF")
: returns the seeding method
used to seed the algorithm that fitted NMF model object
.
See section nmf-methods
.
signature(object = "NMF")
: sets the seeding method
used to seed the algorithm that fitted NMF model object
. signature(object = "NMF")
: standard generic show
method for objects of class NMF
. 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.
Renaud Gaujoux renaud@cbio.uct.ac.za
Main interface to perform NMF in nmf-methods
.
Method seed
to set NMF objects with values suitable to start
algorithms with.
# 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)