gemmr.generative_model._find_latent_mode_vectors

gemmr.generative_model._find_latent_mode_vectors(assemble_Sigmaxy, Sigmaxx, Sigmayy, U, V, _generate_random_subspace_rotations, expl_var_ratio_thr, m, max_n_sigma_trials, qx, qy, rng, true_corrs, uvrots, verbose=True)

Find between-set weight vectors.

  1. determine random between-set weight vectors from the dominant subspace,
    by calling _generate_random_subspace_rotations
  2. add a component from the complementary, low variance, \(px-qx\)
    (for X) and \(py-qy\) (for Y) dimensional subspace
  3. check that resulting latent mode vectors explain enough variance
  4. if so, assemble \(\Sigma_{XY}\), check if it is positive definite,
    and if it is return
  5. if either not enough variance is explained or \(\Sigma_{XY}\) is not
    positive definite, make another attempt to find suitable weight vectors

max_n_sigma_trials attempts are made to find suitable weight vectors in which the weight of the component from the dominant subspace is randomly chosen between 0 and 1. If this is not successful, another max_n_sigma_trials is made in which the the weight for the component from the dominant subspace is increased iteration by iteration from 0.5 to 1. This encourages to obtain a resulting weight vector that overlaps more and more with the dominant subspace so that more variance is explained.

Parameters:
  • assemble_Sigmaxy (function) – either _assemble_Sigmaxy_pls or _assemble_Sigmaxy_cca
  • Sigmaxx (np.ndarray (px, px)) – within-set covariance matrix for X
  • Sigmayy (np.ndarray (py, py)) – within-set covariance matrix for Y
  • U (np.ndarray (px, m)) – weight vectors for X
  • V (np.ndarray (py, m)) – weight vectors for Y
  • _generate_random_subspace_rotations (function) – called to determine a random weight vector living in the dominant subspace
  • expl_var_ratio_thr (float) – the ratio of the amount of variance along the first mode vectors in X and Y to the mean variance along a mode in X and Y needs to surpass this number.
  • m (int >= 1) – number of cross-modality modes to be encoded
  • max_n_sigma_trials (int) – maximum number of attempts made to find a linear combination of dominant and low-variance subspace components for the weight vectors such that both enough variance is explained and the resulting joint covariance matrix \(\Sigma\) is positive definite
  • qx (int) – dimensionality of dominant subspace for X
  • qy (int) – dimensionality of dominant subspace for Y
  • rng (random number generator instance) – for reproducibility, all random numbers will be drawn from this generator
  • true_corrs (np.ndarray (m,)) – true correlation of between-set association modes
  • uvrots (list of 3-tuples where the 2nd and 3rd entries are rotation) – matrices for X and Y, respectively, i.e. np.ndarrays with dimension (qx,) and (qy,)
  • verbose (bool) – whether to print status messages
Returns:

  • min_eval (float) – smallest eigenvalue of Schur complement of joint covariance matrix \(\Sigma\). \(\Sigma\) is positive definite if and only if min_eval > 0
  • Sigmaxy (np.ndarray (px, py)) – between-set covariance matrix
  • Sigmaxy_svals (np.ndarray (m,)) – singular values of Sigmaxy, these are the true canonical correlations or covariances (for CCA or PLS, respectively)
  • U_ (np.ndarray (px, m)) – between-set weight vectors
  • V_ (np.ndarray (py, m)) – between-set weight vectors
  • latent_expl_var_ratios_x (np.ndarray (m,)) – explained variance ratios for between-set weight vectors in set X
  • latent_expl_var_ratios_y (np.ndarray (m,)) – explained variance ratios for between-set weight vectors in set Y
  • true_corrs (np.ndarray (m,)) – true correlations of between-set association modes