Builds a k x n target matrix from class labels, suitable for passing
as target_H to nmf. Each sample column is set
to its class centroid (optionally ZCA-whitened), so that target
regularization steers H toward class-discriminative structure.
Value
A numeric k x n matrix. Pass it to nmf(..., target_H = T,
target_lambda = 0.5) for enrichment or target_lambda = -0.5
for batch removal.
Details
With positive target_lambda, NMF attracts H toward the target
(label enrichment). With negative target_lambda, NMF uses
PROJ_ADV eigenvalue-projected adversarial removal to suppress
target-correlated structure (batch removal). See
vignette("guided-nmf") for mathematical details.
Algorithm:
Compute per-class centroids from rows/columns of
H.(Optional) Apply Oracle-Approximating Shrinkage (OAS) covariance estimation followed by ZCA whitening to the centroids, ensuring isotropic class structure.
Broadcast each sample's class centroid back to a k x n matrix.
Examples
data(hawaiibirds)
model <- nmf(hawaiibirds, k = 4, seed = 42, maxit = 50)
meta <- attr(hawaiibirds, "metadata_h")
# Build target from class labels
target <- compute_target(model@h, labels = meta$island)
# Enrichment: attract H toward island structure
guided <- nmf(hawaiibirds, k = 4, seed = 42, maxit = 50,
target_H = target, target_lambda = 0.5)
# Batch removal: suppress island-correlated structure
removed <- nmf(hawaiibirds, k = 4, seed = 42, maxit = 50,
target_H = target, target_lambda = -0.5)