predict
for NMF models return the
cluster membership of each sample or each feature.
Currently the classification/prediction of new data is
not implemented.predict(object, ...) ## S3 method for class 'NMF':
predict(object,
what = c("columns", "rows", "samples", "features"),
prob = FALSE, dmatrix = FALSE)
## S3 method for class 'NMFfitX':
predict(object,
what = c("columns", "rows", "samples", "features", "consensus", "chc"),
dmatrix = FALSE, ...)
what='samples' or 'columns'
) or each feature
(what='features' or 'rows'
), based on their
corresponding entries in the coefficient matrix or basis
matrix respectively. For example, if what='samples'
, then the dominant
basis component is computed for each column of the
coefficient matrix as the row index of the maximum within
the column.
If argument prob=FALSE
(default), the result is a
factor
. Otherwise a list with two elements is
returned: element predict
contains the cluster
membership index (as a factor
) and element
prob
contains the relative contribution of the
dominant component to each sample (resp. the relative
contribution of each feature to the dominant basis
component):
H[k ,j]
), and$x_{k_0}$is the maximum of these
contributions.W[i, k]
), and$y_{k_0}$is the maximum
of these contributions.Pascual-Montano A, Carazo JM, Kochi K, Lehmann D and Pascual-marqui RD (2006). "Nonsmooth nonnegative matrix factorization (nsNMF)." _IEEE Trans. Pattern Anal. Mach. Intell_, *28*, pp. 403-415.
# roxygen generated flag
options(R_CHECK_RUNNING_EXAMPLES_=TRUE)
# random target matrix
v <- rmatrix(20, 10)
# fit an NMF model
x <- nmf(v, 5)
# predicted column and row clusters
predict(x)
predict(x, 'rows')
# with relative contributions of each basis component
predict(x, prob=TRUE)
predict(x, 'rows', prob=TRUE)
Run the code above in your browser using DataLab