Tutorials › Multi-Omics Data Integration › Tuning Ridge CCA Penalties

Canonical Correlation and Partial Least Squares · Tutorial 136 of 597

Tuning Ridge CCA Penalties

Use leakage-safe cross-validation to compare ridge CCA penalty pairs and select settings that generalize to held-out samples.

Intermediate 12 min read

What You'll Learn

  • Define a candidate grid for the two ridge penalties.
  • Refit centering, scaling, and other transformations within each training split.
  • Calculate and compare held-out canonical-score correlations across folds.
  • Recognize leakage, unstable fold results, and misleading training correlations.
  • Distinguish penalty selection from an independent estimate of final performance.

Why Tune Ridge CCA Penalties?

Ridge-regularized canonical correlation analysis (CCA) uses penalties to stabilize its weight vectors when within-block covariance matrices are poorly conditioned or when the number of features is large relative to the number of paired samples. The penalties affect the fitted canonical directions: a setting that is too weak can leave unstable directions, while one that is too strong can suppress useful cross-block association. The tuning task is to compare candidate penalty settings by how well their fitted scores associate in samples not used to fit them.

The earlier material on Ridge-Regularized CCA supplies the fitted directions. Here, the focus is choosing their two penalty values without allowing validation data to influence model fitting or preprocessing. The target is usually the first canonical-score pair, chosen in advance. If a different score pair or summary is the scientific target, specify that before comparing settings.

Definition: Let \(X\) and \(Y\) be two data blocks measured on the same \(n\) observational units, with \(p\) and \(q\) features. For a training set, let \(S_{xx}\), \(S_{yy}\), and \(S_{xy}\) be the sample covariance and cross-covariance matrices after the specified training-set preprocessing. For nonnegative penalties \(\lambda_x\) and \(\lambda_y\), ridge CCA chooses weight vectors \(a\) and \(b\) to maximize
$$ \frac{a^\mathsf{T}S_{xy}b} {\sqrt{\{a^\mathsf{T}(S_{xx}+\lambda_x I_p)a\} \{b^\mathsf{T}(S_{yy}+\lambda_y I_q)b\}}}. $$
The resulting scores are formed from the two blocks using those weights. A tuning procedure evaluates these fitted directions on held-out paired units, using only transformations estimated from the corresponding training set.

The penalties are defined relative to the scale of the covariance matrices. A practical grid is interpretable only alongside a stated scaling convention: for example, centering and scaling each feature using the training-set mean and sample standard deviation, then forming sample covariance matrices. In that convention, the penalty is relative to the standardized covariance scale. The grid must also include values for which the regularized fits are numerically computable; when an unregularized covariance matrix is singular, a zero penalty may not be feasible.

A Fold-Based Selection Procedure

Partition the paired observational units into \(K\) folds. For each candidate pair \((\lambda_x,\lambda_y)\), fit ridge CCA using \(K-1\) folds and calculate the correlation between the two fitted scores in the remaining fold. Repeat until each fold has served as validation data. Orient the fitted score pair consistently using the training data—for example, choose the sign of one weight vector so that the training cross-block score correlation is nonnegative. Do not flip a score sign based on its validation correlation: that would use validation outcomes to improve the validation metric.

$$ r_k(\lambda_x,\lambda_y) = \operatorname{cor}\!\left( X_{V_k}^{*}a_{-k},\, Y_{V_k}^{*}b_{-k} \right), \qquad \bar r_{\mathrm{CV}}(\lambda_x,\lambda_y) = \frac{1}{K}\sum_{k=1}^{K} r_k(\lambda_x,\lambda_y). $$

Here, \(V_k\) is the set of held-out units in fold \(k\); \(a_{-k}\) and \(b_{-k}\) are fitted on the other folds; and \(X_{V_k}^{*}\) and \(Y_{V_k}^{*}\) denote validation features transformed using parameters estimated from those training folds. The correlation is the ordinary Pearson correlation within the validation fold. A simple selection rule is to choose the candidate pair with the largest mean fold correlation. Report the fold-specific values as well as the mean, because similar means can conceal very different stability across folds.

The correlation is calculated within each validation fold, not by blindly concatenating scores from different fits. Each fold has its own fitted weights and preprocessing parameters; scores from different folds need not have comparable means or scales. Foldwise correlations avoid treating the fold-specific score coordinates as if they came from one common fitted model. If fold sizes differ, a prespecified size-weighted summary may be reasonable, but the weighting rule should be stated and used consistently.

1
Define the candidate grid.
Choose plausible nonnegative values for both penalties and state the feature-scaling convention. Keep the grid fixed across folds.
2
Split paired units.
Assign the same observational units to corresponding folds in both blocks. If several rows come from one person or other grouped unit, keep that group together.
3
Refit the full pipeline.
Within each training split, estimate preprocessing parameters, form covariance matrices, and fit ridge CCA for every candidate pair.
4
Score held-out units.
Apply the training-set transformations and fitted weights to the validation features, then calculate the validation score correlation.
5
Compare and select.
Summarize fold correlations for each pair, consider their variability, and select using the prespecified rule. Do not use a final test set to choose the penalties.

Worked Examples

Worked Example: Calculating a Held-Out Correlation

Consider one hypothetical validation fold with fitted \(X\)-block scores \(1,2,3,4\) and fitted \(Y\)-block scores \(2,1,4,3\). These scores were generated by a ridge CCA fit on the other folds, and the sign orientation was set using training data. The fold contains four distinct paired units, with no repeated unit split across training and validation.

The validation means are both \(2.5\). The centered scores are \((-1.5,-0.5,0.5,1.5)\) and \((-0.5,-1.5,1.5,0.5)\). Thus, the cross-product sum is \(0.75+0.75+0.75+0.75=3\), and each centered sum of squares is \(5\). Therefore,

$$ r_{\mathrm{val}} = \frac{3}{\sqrt{5\cdot 5}} = 0.600. $$

The fitted score association in this hypothetical fold is positive and moderate. This is a fold-specific validation result, not evidence that the population correlation equals \(0.600\); one small fold also gives a noisy estimate.

Worked Example: Comparing Penalty Pairs Across Folds

Suppose three candidate penalty pairs were evaluated on the same three hypothetical folds. Every fold used matched units, and centering, scaling, and ridge CCA were refit using only that fold’s training units. The table gives the resulting held-out correlations.

Candidate pairFold 1Fold 2Fold 3Mean
A: \((0.01,0.01)\)0.600.550.650.600
B: \((0.10,0.10)\)0.720.680.700.700
C: \((1.00,1.00)\)0.800.200.600.533

For candidate B, \((0.72+0.68+0.70)/3=2.10/3=0.700\). The other means are \((0.60+0.55+0.65)/3=0.600\) and \((0.80+0.20+0.60)/3=1.60/3=0.533\). By the prespecified largest-mean rule, candidate B is selected. Candidate C illustrates why the mean alone is not the whole report: its fold results vary much more, and its strong first-fold result does not persist. These hypothetical values support selecting B for refitting, not claiming that its future correlation is exactly \(0.700\).

Worked Example: Keeping Validation Scaling Separate

Suppose a single hypothetical feature in a training split has values \(2,4,6\), and a held-out unit has value \(100\). The training mean is \(\bar{x}=4\), and the training sample standard deviation is \(s=\sqrt{\{(2-4)^2+(4-4)^2+(6-4)^2\}/2}=2\). The validation value is transformed using these training estimates:

$$ z_{\mathrm{val}}=\frac{100-4}{2}=48. $$

If the validation value were incorrectly included when estimating the mean and standard deviation, the four-value mean would be \(28\), and the sample standard deviation would be \(\sqrt{6920/3}\approx48.03\). The transformed validation value would then be \((100-28)/48.03\approx1.499\), a very different quantity. This calculation does not show that the correct score must be large; it shows that allowing validation data to set a transformation changes the fitted procedure. The correct cross-validation pipeline estimates scaling from training data only, then applies it unchanged to validation data.

Why the Procedure Works—and Where It Can Fail

Within a fold, the fitted weights and transformations are functions of the training observations. Conditional on that training data, the held-out observations did not determine those fitted quantities. Their score correlation therefore evaluates the fitted procedure on data not used to estimate its directions, unlike the training correlation, which is optimized by construction. The justification can be stated directly: for each fold, the validation score vectors use \(a_{-k}\), \(b_{-k}\), and training-fitted transformations, while the validation units are excluded from those fits. The fold correlation consequently measures how well those training-fitted scores co-vary in held-out units.

This separation is only as good as the split and pipeline. The two blocks must remain correctly paired; splitting rows independently across blocks destroys the intended correspondence. Repeated measurements or related samples should be grouped so that information from the same underlying unit cannot occur in both training and validation. Any data-dependent step—imputation, feature filtering, batch correction, scaling, or dimension reduction—must be estimated within each training split. A fixed transformation specified without reference to the data may be applied consistently, but a transformation estimated from all observations leaks validation information.

There is also selection optimism. The largest of many noisy cross-validation means tends to be optimistic as an estimate of the selected model’s future performance, because the same fold results both select and evaluate the winning candidate. If an unbiased final performance estimate is important, reserve an independent test set before tuning, or use nested cross-validation: the inner folds select penalties, and outer held-out folds evaluate the entire selection-and-fitting procedure. After selection, refit the chosen pipeline on all development data; do not change the penalties after inspecting test performance.

ApproachStrengthMain caution
Choose penalties from training canonical correlationComputationally simpleThe fitted objective is optimized on those data and can reward overfitting.
Choose penalties by cross-validated score correlationCompares generalization across training splitsThe selected maximum can still be optimistic; fold results can be noisy.
Choose penalties on development data and evaluate once on an independent test setSeparates selection from final evaluationRequires enough data to retain a useful test set; the test set must remain untouched until evaluation.

Held-out correlations are diagnostics as well as selection criteria. A candidate whose fold correlations change sharply in sign or magnitude may be unstable, even if its mean is competitive. Inspect whether a small number of folds dominate the result, whether the selected pair lies at the edge of the grid, and whether rankings change substantially under reasonable alternative fold assignments. A boundary winner suggests expanding or reconsidering the grid; it does not prove that the true best penalty lies outside it. Repeated cross-validation can show sensitivity to partitioning, but it does not create additional independent observational units.

The procedure has limits. Correlation measures linear association between the two fitted score vectors and does not establish causation or guarantee that individual features have stable interpretations. Small validation folds produce imprecise correlations, and extensive tuning over a large grid increases selection noise. The largest mean may therefore not be meaningfully better than nearby candidates. Report the grid, preprocessing, fold design, foldwise correlations, selection rule, and any independent evaluation. When results are nearly tied, a simpler prespecified choice among comparable candidates may be easier to justify than treating a tiny difference in mean correlation as decisive.

Common Mistakes

  • Using validation observations to preprocess. The wrong reasoning is that scaling is “not part of CCA,” so it can be calculated once on all samples. The correction is that any data-estimated transformation is part of the fitted pipeline and must be refit within each training split.
  • Selecting by training correlation. A high training correlation is not a fair comparison of generalization, because the directions were chosen to maximize training association. Compare held-out correlations instead.
  • Flipping signs using validation data. Canonical directions have sign ambiguity, but validation results cannot decide the sign during evaluation. Set orientation from training data and retain it in validation.
  • Treating the winning cross-validation mean as an unbiased final estimate. The winning candidate was selected for performing well on those folds. Use an untouched test set or nested cross-validation for final evaluation.
Key takeaway: Tune ridge CCA by comparing held-out score correlations, while refitting every data-dependent transformation and the CCA model within each training split. Select with a prespecified rule, inspect fold stability, and separate tuning from final performance evaluation.

Check Your Understanding

Try each question, then compare your reasoning with the solutions below.

  1. In a fold-based comparison, should the validation fold contribute to the feature means and standard deviations? Explain why.
  2. Two penalty pairs have mean held-out correlations of \(0.64\) and \(0.65\). The first has similar results across folds; the second ranges from \(0.10\) to \(0.90\). What should be reported or investigated before treating the second as better?
  3. Why is it not appropriate to flip a validation score sign whenever doing so increases the validation correlation?
  4. After choosing penalties by cross-validation, what is one appropriate way to obtain a separate estimate of performance?

Solutions. (1) No. Estimate both quantities in the training fold and apply them to validation features; otherwise the held-out observations influence the fitted pipeline. (2) Report the fold-specific values and investigate sensitivity to the fold assignment; the nearly equal means do not establish that the variable second candidate is superior. (3) That choice uses validation outcomes to improve the evaluation statistic, so it no longer evaluates the training-fitted procedure. Orient the scores using training data. (4) Evaluate the selected procedure once on an independent test set kept untouched during tuning, or use outer folds in nested cross-validation.

Clinical Biostats