Compute Cluster-wise Subspace Recovery Score
Source:R/evaluation_wrappers.R
compute_clusterwise_subspace_score.RdComputes subspace similarity scores for each cluster, using the aligned mapping between estimated and true clusters. This provides a detailed assessment of how well each cluster's subspace is recovered.
Arguments
- true_Lambda_list
List of K_true matrices, each (M x r) representing true cluster-specific basis matrices.
- est_Lambda_list
List of K_hat matrices, each (M x r_hat) representing estimated cluster-specific basis matrices.
- mapping
Named integer vector from
align_clusters_to_truth, mapping estimated cluster labels to true cluster labels.
Value
A list with:
scoresNamed numeric vector of subspace similarity scores for each true cluster (names are cluster indices as characters).
mean_scoreNumeric scalar: mean of non-NA scores.
n_matchedInteger: number of true clusters with a valid estimated match.
Returns a list with NA values if inputs are invalid.
Details
For each true cluster k:
Find the estimated cluster that maps to k (using the mapping)
Compute subspace similarity between true_Lambda_list[[k]] and the corresponding estimated basis
If no estimated cluster maps to k, the score is NA
This function is NA-safe: if estimation failed for some clusters (NULL or invalid matrices), those clusters receive NA scores and are excluded from the mean calculation.
Examples
if (FALSE) { # \dontrun{
# Generate data and fit model
data <- generate_synergy_data(N = 30, K = 3, r = 2, seed = 123)
fit <- mfa_em_fit(data$list_of_data, K = 3, r = 2)
# Align clusters
alignment <- align_clusters_to_truth(data$true_cluster, fit$z)
# Compute cluster-wise scores
scores <- compute_clusterwise_subspace_score(
data$true_Lambda_list,
fit$Lambda,
alignment$mapping
)
} # }