maxfuse.utils.cca_embedding

maxfuse.utils.cca_embedding(arr1, arr2, init_matching, filter_prop, n_components, max_iter=2000)[source]

Filter bad matched pairs, align arr1 and arr2 using init_matching, fit CCA, and get CCA embeddings of arr1 and arr2.

Parameters:
  • arr1 (np.ndarray of shape (n_samples1, n_features1)) – The first data matrix

  • arr2 (np.ndarray of shape (n_samples2, n_features2)) – The second data matrix

  • init_matching (list) – rows, cols, vals = init_matching, where each matched pair is (rows[i], cols[i]), and their distance is vals[i]

  • filter_prop (float) – Matched pairs with distance in top filter_prop are discarded when fitting CCA

  • n_components (int) – Number of components to keep when fitting CCA

  • max_iter (int, default=2000) – Maximum number of iterations for CCA

Returns:

  • arr1_cca (np.array of shape (n_samples1, n_components))

  • arr2_cca (np.array of shape (n_samples2, n_components))

  • canonical_correlations (np.array of shape (n_components,))