Skip to contents

Same as the evaluate S4 method for the nmf class, but allows one to input the `w`, `d`, `h`, and `data` independently.

Usage

mse(w, d = NULL, h, data, mask = NULL, missing_only = FALSE, ...)

Arguments

w

feature factor matrix (features as rows)

d

scaling diagonal vector (if applicable)

h

sample factor matrix (samples as columns)

data

dense or sparse matrix of features in rows and samples in columns. Prefer matrix or Matrix::dgCMatrix, respectively. Also accepts a file path (character string) which will be auto-loaded based on extension.

mask

missing data mask. Accepts: NULL (no masking), "zeros" (mask zeros), "NA" (mask NAs), a dgCMatrix/matrix (custom mask), or list("zeros", <matrix>) to mask zeros and use a custom mask simultaneously.

missing_only

only calculate mean squared error at masked values

...

additional arguments

Value

A single numeric value: the mean squared error of the factorization.

Examples

if (FALSE) { # \dontrun{
data <- simulateNMF(50, 30, k = 3, seed = 1)
model <- nmf(data$A, 3, seed = 1, maxit = 50)
RcppML:::mse(model$w, model$d, model$h, data$A)
} # }