Description Usage Arguments Details Value Note See Also Examples
The functions documented here tests different characteristics of NMF objects.
is.nmf
tests if an object is an NMF model or a class that extends
the class NMF.
1 2 3 4 5 6 7 8 9 10 11 | is.nmf(x)
is.empty.nmf(x, ...)
hasBasis(x)
hasCoef(x)
is.partial.nmf(x)
isNMFfit(object, recursive = TRUE)
|
x |
an R object. See section Details, for how each function uses this argument. |
... |
extra parameters to allow extension or passed to subsequent calls |
object |
any R object. |
recursive |
if |
is.nmf
tests if object
is the name of a class (if a character
string), or inherits from a class, that extends NMF
.
is.empty.nmf
returns TRUE
if the basis and coefficient matrices of
x
have respectively zero rows and zero columns.
It returns FALSE
otherwise.
In particular, this means that an empty model can still have a non-zero number
of basis components, i.e. a factorization rank that is not null.
This happens, for example, in the case of NMF models created calling the factory method
nmfModel
with a value only for the factorization rank.
isNMFfit checks if object
inherits from class
NMFfit
or NMFfitX
, which are
the two types of objects returned by the function nmf
.
If object
is a plain list
and recursive=TRUE
, then
the test is performed on each element of the list, and the return value
is a logical vector (or a list if object
is a list of list) of
the same length as object
.
isNMFfit
returns a logical
vector (or a list if
object
is a list of list) of the same length as object
.
The function is.nmf
does some extra work with the namespace as
this function needs to return correct results even when called in .onLoad
.
See discussion on r-devel: https://stat.ethz.ch/pipermail/r-devel/2011-June/061357.html
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 | # test if an object is an NMF model, i.e. that it implements the NMF interface
is.nmf(1:4)
is.nmf('NMFstd')
is.nmf('NMFblah')
is.nmf( nmfModel(3) )
is.nmf( nmf(rmatrix(20,10), 3) )
# empty model
is.empty.nmf( nmfModel(3) )
# non empty models
is.empty.nmf( nmfModel(3, 10, 0) )
is.empty.nmf( rnmf(3, 10, 5) )
## Testing results of fits
# generate a random
V <- rmatrix(20, 10)
# single run -- using very low value for maxIter to speed up the example
res <- nmf(V, 3, maxIter=3L)
isNMFfit(res)
# multiple runs - keeping single fit
resm <- nmf(V, 3, nrun=3, maxIter=3L)
isNMFfit(resm)
# multiple runs - keeping all fits
resM <- nmf(V, 3, nrun=3, .opt='k', maxIter=3L)
isNMFfit(resM)
# with a list of results
isNMFfit(list(res, resm, resM, 'not a result'))
isNMFfit(list(res, list(resm, resM), 'not a result')) # list of list
isNMFfit(list(res, resm, resM, 'not a result'), recursive=FALSE)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.