Description Usage Arguments Details Slots Methods (by generic) Examples
Base class to handle the results of general Nonnegative Matrix Factorisation algorithms (NMF).
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 | NMFfit(fit = nmfModel(), ..., rng = NULL)
## S4 method for signature 'NMFfit'
fitted(object, ...)
## S4 method for signature 'NMFfit'
.basis(object, ...)
## S4 replacement method for signature 'NMFfit,matrix'
.basis(object) <- value
## S4 method for signature 'NMFfit'
.coef(object, ...)
## S4 replacement method for signature 'NMFfit,matrix'
.coef(object) <- value
## S4 method for signature 'NMFfit'
ibterms(object)
## S4 method for signature 'NMFfit'
icterms(object)
## S4 method for signature 'NMFfit'
offset(object)
## S4 method for signature 'NMFfit'
niter(object, ...)
## S4 replacement method for signature 'NMFfit,numeric'
niter(object) <- value
## S4 method for signature 'NMFfit'
show(object)
## S4 method for signature 'NMFfit'
fit(object)
## S4 replacement method for signature 'NMFfit,NMF'
fit(object) <- value
## S4 method for signature 'NMFfit'
minfit(object)
## S4 method for signature 'NMFfit'
modelname(object)
## S4 method for signature 'NMFfit'
algorithm(object)
## S4 replacement method for signature 'NMFfit,ANY'
algorithm(object) <- value
## S4 method for signature 'NMFfit'
seeding(object)
## S4 replacement method for signature 'NMFfit'
seeding(object) <- value
## S4 method for signature 'NMFfit'
objective(object, y)
## S4 replacement method for signature 'NMFfit,ANY'
objective(object) <- value
## S4 method for signature 'NMFfit'
runtime(object, ...)
## S4 method for signature 'NMFfit'
runtime.all(object, ...)
## S4 method for signature 'NMFfit,missing'
plot(x, y, skip = -1L, ...)
## S4 method for signature 'NMFfit'
summary(object, ...)
## S4 method for signature 'NMFfit,NMF'
nmf.equal(x, y, ...)
## S4 method for signature 'NMFfit,NMFfit'
nmf.equal(x, y, ...)
## S4 method for signature 'NMFfit'
nrun(object)
## S4 method for signature 'NMFfit'
consensus(object, ...)
## S4 method for signature 'NMFfit'
icterms(object)
|
fit |
an NMF model |
... |
extra arguments passed to base graphics |
rng |
RNG settings specification (typically a suitable value for
|
object |
an object of class |
value |
an object used to modify the properties of the object.
Depending on the method, it may be a |
y |
optional target matrix used to compute the objective value. |
x |
an NMF object as returned by |
skip |
an integer that indicates the number of points to skip/remove from the beginning
of the curve.
If |
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
An object that inherits from class NMF
, and
contains the fitted NMF model.
NB: 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 fitted the NMF
model.
Default value is ''
. See nmf
for more details.
rng
an object that contains the RNG settings used for the
fit.
Currently the settings are stored as an integer vector, the value of
.Random.seed
at the time the object is created.
It is initialized by the initialized
method.
See getRNG
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.
See objective
and deviance,NMF-method
.
parameters
a list
that contains the extra parameters
– usually specific to the algorithm – that were 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
for internal usage only.
For example it can be used to store extra parameters or temporary data,
without the need to explicitly extend the NMFfit
class.
Currently built-in algorithms only use this slot to
store the number of iterations performed to fit the object.
Data that need to be easily accessible by the end-user should rather be set
using the methods $<-
that sets elements in the list
slot
misc
– that is inherited from class NMF
.
call
stored call to the last nmf
method that generated the
object.
.basis:
.basis(object = NMFfit)
: Returns the basis matrix from an NMF model fitted with
function nmf
.
It is a shortcut for .basis(fit(object), ...)
, dispatching the call to
the .basis
method of the actual NMF model.
.basis<-:
.basis<-(object = NMFfit,value = matrix)
: Sets the the basis matrix of an NMF model fitted with
function nmf
.
It is a shortcut for .basis(fit(object)) <- value
, dispatching the call to
the .basis<-
method of the actual NMF model.
It is not meant to be used by the user, except when developing
NMF algorithms, to update the basis matrix of the seed object before
returning it.
.coef:
.coef(object = NMFfit)
: Returns the the coefficient matrix from an NMF model fitted with
function nmf
.
It is a shortcut for .coef(fit(object), ...)
, dispatching the call to
the .coef
method of the actual NMF model.
.coef<-:
.coef<-(object = NMFfit,value = matrix)
: Sets the the coefficient matrix of an NMF model fitted with
function nmf
.
It is a shortcut for .coef(fit(object)) <- value
, dispatching the call to
the .coef<-
method of the actual NMF model.
It is not meant to be used by the user, except when developing
NMF algorithms, to update the coefficient matrix in the seed object before
returning it.
algorithm:
algorithm(object = NMFfit)
: Returns the name of the algorithm that fitted the NMF model object
.
compare:
compare(object = NMFfit)
: Compare multiple NMF fits passed as arguments.
consensus:
consensus(object = NMFfit)
: Shorcut for consensus(fit(object), ...)
deviance:
deviance(object = NMFfit)
: Returns the deviance of a fitted NMF model.
This method returns the final residual value if the target matrix y
is
not supplied, or the approximation error between the fitted NMF model stored
in object
and y
.
In this case, the computation is performed using the objective function
method
if not missing, or the objective of the algorithm that
fitted the model (stored in slot 'distance'
).
If not computed by the NMF algorithm itself, the value is automatically
computed at the end of the fitting process by the function nmf
,
using the objective function associated with the NMF algorithm, so that it
should always be available.
fit:
fit(object = NMFfit)
: Returns the NMF model object stored in slot 'fit'
.
fit<-:
fit<-(object = NMFfit,value = NMF)
: Updates the NMF model object stored in slot 'fit'
with a new value.
fitted:
fitted(object = NMFfit)
: Computes and return the estimated target matrix from an NMF model fitted with
function nmf
.
It is a shortcut for fitted(fit(object), ...)
, dispatching the call to
the fitted
method of the actual NMF model.
ibterms:
ibterms(object = NMFfit)
: Method for single NMF fit objects, which returns the indexes of fixed
basis terms from the fitted model.
icterms:
icterms(object = NMFfit)
: Method for single NMF fit objects, which returns the indexes of fixed
coefficient terms from the fitted model.
icterms(object = NMFfit)
: Method for multiple NMF fit objects, which returns the indexes of fixed
coefficient terms from the best fitted model.
minfit:
minfit(object = NMFfit)
: Returns the object its self, since there it is the result of a single NMF run.
modelname:
modelname(object = NMFfit)
: Returns the type of a fitted NMF model.
It is a shortcut for modelname(fit(object)
.
niter:
niter(object = NMFfit)
: Returns the number of iteration performed to fit an NMF model, typically
with function nmf
.
Currently this data is stored in slot 'extra'
, but this might change
in the future.
niter<-:
niter<-(object = NMFfit,value = numeric)
: Sets the number of iteration performed to fit an NMF model.
This function is used internally by the function nmf
.
It is not meant to be called by the user, except when developing
new NMF algorithms implemented as single function, to set the number
of iterations performed by the algorithm on the seed, before returning it
(see NMFStrategyFunction
).
nmf.equal:
nmf.equal(x = NMF,y = NMFfit)
: Compares two NMF models when at least one comes from a NMFfit object,
i.e. an object returned by a single run of nmf
.
nmf.equal(x = NMFfit,y = NMF)
: Compares two NMF models when at least one comes from a NMFfit object,
i.e. an object returned by a single run of nmf
.
nmf.equal(x = NMFfit,y = NMFfit)
: Compares two fitted NMF models, i.e. objects returned by single runs of
nmf
.
NMFfitX:
NMFfitX(object = NMFfit)
: Creates an NMFfitX1
object from a single fit.
This is used in nmf
when only the best fit is kept in memory or
on disk.
nrun:
nrun(object = NMFfit)
: This method returns the number of runs used to compute a fitted NMF model (in fit(object)
).
This will be 1L
most of the time, since an NMFfit
object is generally from a
single NMF run, except in special nested fits.
objective:
objective(object = NMFfit)
: Returns the objective function associated with the algorithm that computed the
fitted NMF model object
, or the objective value with respect to a given
target matrix y
if it is supplied.
offset:
offset(object = NMFfit)
: Returns the offset from the fitted model.
plot:
plot(x = NMFfit,y = missing)
: Plots the residual track computed at regular interval during the fit of
the NMF model x
.
residuals:
residuals(object = NMFfit)
: Returns the residuals – track – between the target matrix and the NMF
fit object
.
run:
run(object = NMFStrategy,y = mMatrix,x = NMFfit)
: Pure virtual method defined for all NMF algorithms to ensure
that a method run
is defined by sub-classes of NMFStrategy
.
It throws an error if called directly.
run(object = NMFStrategyFunction,y = matrix,x = NMFfit)
: Runs the NMF algorithms implemented by the single R function – and stored in slot 'algorithm'
of object
, on the data object y
, using x
as starting point.
It is equivalent to calling object@algorithm(y, x, ...)
.
This method is usually not called directly, but only via the function nmf
, which
takes care of many other details such as seeding the computation, handling RNG settings, or setting up
parallelisation.
run(object = NMFStrategyIterative,y = mMatrix,x = NMFfit)
: Runs an NMF iterative algorithm on a target matrix y
.
run(object = NMFStrategyOctave,y = matrix,x = NMFfit)
: Runs the NMF algorithms implemented by the Octave/Matlab function associated with the
strategy – and stored in slot 'algorithm'
of object
.
This method is usually not called directly, but only via the function nmf
, which
takes care of many other details such as seeding the computation, handling RNG settings,
or setting up parallel computations.
runtime:
runtime(object = NMFfit)
: Returns the CPU time required to compute a single NMF fit.
runtime.all:
runtime.all(object = NMFfit)
: Identical to runtime
, since their is a single fit.
seeding:
seeding(object = NMFfit)
: Returns the name of the seeding method that generated the starting point
for the NMF algorithm that fitted the NMF model object
.
show:
show(object = NMFfit)
: Show method for objects of class NMFfit
summary:
summary(object = NMFfit)
: Computes summary measures for a single fit from nmf
.
This method adds the following measures to the measures computed by the method
summary,NMF
:
Residual error as measured by the objective function associated to the algorithm used to fit the model.
Number of iterations performed to achieve convergence of the algorithm.
Total CPU time required for the fit.
Total CPU time required for the fit. For NMFfit
objects, this element is
always equal to the value in “cpu”, but will be different for multiple-run fits.
Number of runs performed to fit the model. This is always equal to 1 for
NMFfit
objects, but will vary for multiple-run fits.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | # run default NMF algorithm on a random matrix
n <- 50; r <- 3; p <- 20
V <- rmatrix(n, p)
res <- nmf(V, r)
# result class is NMFfit
class(res)
isNMFfit(res)
# show result
res
# compute summary measures
summary(res, target=V)
# generate a synthetic dataset with known classes: 50 features, 18 samples (5+5+8)
n <- 50; counts <- c(5, 5, 8);
V <- syntheticNMF(n, counts)
cl <- unlist(mapply(rep, 1:3, counts))
# perform default NMF with rank=2
x2 <- nmf(V, 2)
summary(x2, cl, V)
# perform default NMF with rank=2
x3 <- nmf(V, 3)
summary(x2, cl, V)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.