| nmfkc.cv | R Documentation |
nmfkc.cv performs k-fold cross-validation for the tri-factorization model
Y \approx X C A = X B, where
Y(P,N) is the observation matrix,
A(R,N) is the covariate (or kernel) matrix,
X(P,Q) is the basis matrix,
C(Q,R) is the parameter matrix, and
B(Q,N) is the coefficient matrix (B = C A).
Given Y (and optionally A), X and C are fitted on each
training split and predictive performance is evaluated on the held-out split.
nmfkc.cv(Y, A = NULL, rank = 2, data, ...)
Y |
Observation matrix, or a formula (see |
A |
Covariate matrix. If |
rank |
Rank of the basis matrix |
data |
A data frame (required when |
... |
Additional arguments controlling CV and the internal
|
A list with components:
objfuncMean loss per valid entry over all folds (MSE for method="EU").
sigmaResidual standard error (RMSE). Available only if method="EU"; on the same scale as Y.
objfunc.blockLoss for each fold.
blockVector of fold indices (1, …, div) assigned to each column of Y.
nmfkc, nmfkc.kernel.beta.cv, nmfkc.ar.degree.cv
# Example 1 (with explicit covariates):
Y <- matrix(cars$dist, nrow = 1)
A <- rbind(1, cars$speed)
res <- nmfkc.cv(Y, A, rank = 1)
res$objfunc
# Example 2 (kernel A and beta sweep):
Y <- matrix(cars$dist, nrow = 1)
U <- matrix(c(5, 10, 15, 20, 25), nrow = 1)
V <- matrix(cars$speed, nrow = 1)
betas <- 25:35/1000
obj <- numeric(length(betas))
for (i in seq_along(betas)) {
A <- nmfkc.kernel(U, V, beta = betas[i])
obj[i] <- nmfkc.cv(Y, A, rank = 1, nfolds = 10)$objfunc
}
betas[which.min(obj)]
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.