cca_zoo.linear¶
Linear CCA methods. All classes are sklearn.base.BaseEstimator subclasses.
Base class¶
BaseModel ¶
Bases: BaseEstimator, ABC
Abstract base class for all multiview CCA models.
Subclasses must implement :meth:fit. All other public methods
(transform, fit_transform, score, pairwise_correlations,
average_pairwise_correlations, get_factor_loadings) are provided
here using the weights_ attribute set by fit.
This class inherits from :class:sklearn.base.BaseEstimator so that
get_params / set_params round-trip correctly and sklearn model
selection utilities work out of the box.
Constructor parameters are validated with sklearn's
_parameter_constraints mechanism (see :meth:_setup_fit).
Subclasses that add their own constructor parameters may extend
_parameter_constraints by merging in BaseModel._parameter_constraints;
parameters with no declared constraint are left unvalidated, so this is
always safe to skip.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
latent_dimensions
|
int
|
Number of latent dimensions to fit. Default is 1. |
1
|
center
|
bool
|
Whether to subtract per-view column means before fitting.
The means are stored in |
True
|
weights
property
¶
Weight matrices post-fit, one per view.
Shape is (n_features_i, latent_dimensions) for each view.
Raises:
| Type | Description |
|---|---|
NotFittedError
|
If |
fit
abstractmethod
¶
Fit the model to multiview data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
views
|
list[ArrayLike]
|
List of arrays, each of shape (n_samples, n_features_i). All arrays must have the same number of rows. |
required |
y
|
None
|
Ignored. Present for scikit-learn API compatibility. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
self |
BaseModel
|
Fitted estimator. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If fewer than 2 views are provided. |
ValueError
|
If views have inconsistent numbers of samples. |
transform ¶
Project views into the latent space using the fitted weights.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
views
|
list[ArrayLike]
|
List of arrays, each of shape (n_samples, n_features_i). |
required |
Returns:
| Type | Description |
|---|---|
list[ndarray]
|
List of arrays, each of shape (n_samples, latent_dimensions). |
Raises:
| Type | Description |
|---|---|
NotFittedError
|
If |
fit_transform ¶
Fit and then transform the training data.
Equivalent to self.fit(views).transform(views) but may be more
efficient for some subclasses.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
views
|
list[ArrayLike]
|
List of arrays, each of shape (n_samples, n_features_i). |
required |
y
|
None
|
Ignored. |
None
|
Returns:
| Type | Description |
|---|---|
list[ndarray]
|
List of arrays, each of shape (n_samples, latent_dimensions). |
score ¶
Return average pairwise canonical correlations for each dimension.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
views
|
list[ArrayLike]
|
List of arrays, each of shape (n_samples, n_features_i). |
required |
y
|
None
|
Ignored. |
None
|
Returns:
| Type | Description |
|---|---|
ndarray
|
Array of shape |
ndarray
|
pairwise correlation for each canonical dimension. |
pairwise_correlations ¶
Compute the full pairwise correlation matrix per latent dimension.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
views
|
list[ArrayLike]
|
List of arrays, each of shape (n_samples, n_features_i). |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
Array of shape |
ndarray
|
entry |
ndarray
|
d-th canonical variate of view i and view j. |
average_pairwise_correlations ¶
Return the mean off-diagonal pairwise correlation per dimension.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
views
|
list[ArrayLike]
|
List of arrays, each of shape (n_samples, n_features_i). |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
Array of shape |
ndarray
|
off-diagonal pairwise correlation for each canonical dimension. |
get_factor_loadings ¶
Compute canonical factor loadings for each view.
A loading is the Pearson correlation between an original feature and a canonical variate. Loadings indicate which original variables drive each canonical direction.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
views
|
list[ArrayLike]
|
List of arrays, each of shape (n_samples, n_features_i). |
required |
Returns:
| Type | Description |
|---|---|
list[ndarray]
|
List of arrays, each of shape (n_features_i, latent_dimensions), |
list[ndarray]
|
where entry |
list[ndarray]
|
view i and the d-th canonical variate of view i. |
Two-view exact methods¶
CCA ¶
Bases: rCCA
Canonical Correlation Analysis.
Finds the pair of linear projections that maximise the Pearson correlation between two views subject to unit within-view variance constraints:
This is a special case of :class:rCCA with c=0. The solution uses
PCA whitening followed by an SVD of the cross-covariance matrix, which is
numerically stable even for high-dimensional views.
References
Hotelling, H. (1936). Relations between two sets of variates. Biometrika, 28(3/4), 321–377.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
latent_dimensions
|
int
|
Number of latent dimensions. Default is 1. |
1
|
center
|
bool
|
Whether to subtract column means before fitting. Default True. |
True
|
Example
import numpy as np rng = np.random.default_rng(0) X1 = rng.standard_normal((50, 10)) X2 = rng.standard_normal((50, 8)) model = CCA(latent_dimensions=2).fit([X1, X2]) corrs = model.score([X1, X2])
Source code in cca_zoo/linear/_cca.py
fit ¶
Fit the CCA model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
views
|
list[ArrayLike]
|
List of exactly two arrays, each (n_samples, n_features_i). |
required |
y
|
None
|
Ignored. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
self |
CCA
|
Fitted estimator. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the number of views is not exactly 2. |
ValueError
|
If views have inconsistent numbers of samples. |
Example
import numpy as np rng = np.random.default_rng(0) X1 = rng.standard_normal((50, 10)) X2 = rng.standard_normal((50, 8)) model = CCA(latent_dimensions=2).fit([X1, X2])
Source code in cca_zoo/linear/_cca.py
rCCA ¶
Bases: BaseModel
Regularised Canonical Correlation Analysis (canonical ridge).
Finds the pair of linear projections of two views that maximise their correlation subject to regularised within-view variance constraints:
The solution is found by whitening each view with its regularised covariance matrix and computing the SVD of the resulting cross-covariance.
:class:CCA (c=0) and :class:PLS (c=1) are special cases.
References
Vinod, H. D. (1976). Canonical ridge and econometrics of joint production. Journal of Econometrics, 4(2), 147–166.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
latent_dimensions
|
int
|
Number of latent dimensions. Default is 1. |
1
|
center
|
bool
|
Whether to subtract column means before fitting. Default True. |
True
|
c
|
float | list[float]
|
Ridge regularisation parameter(s) in |
0.0
|
Example
import numpy as np rng = np.random.default_rng(0) X1 = rng.standard_normal((50, 10)) X2 = rng.standard_normal((50, 8)) model = rCCA(latent_dimensions=2, c=0.1).fit([X1, X2]) scores = model.transform([X1, X2])
Source code in cca_zoo/linear/_rcca.py
fit ¶
Fit the rCCA model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
views
|
list[ArrayLike]
|
List of exactly two arrays, each (n_samples, n_features_i). |
required |
y
|
None
|
Ignored. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
self |
rCCA
|
Fitted estimator. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the number of views is not exactly 2. |
ValueError
|
If views have inconsistent numbers of samples. |
Source code in cca_zoo/linear/_rcca.py
PLS ¶
Bases: rCCA
Partial Least Squares (two-view).
Finds the pair of unit-norm weight vectors that maximise the covariance between the projected views:
This is equivalent to the truncated SVD of the sample cross-covariance
matrix \(X_1^\top X_2 / (n - 1)\), and corresponds to :class:rCCA
with c=1.
References
Wold, H. (1975). Soft modelling by latent variables: the nonlinear iterative partial least squares (NIPALS) approach. Perspectives in Probability and Statistics, 117–142.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
latent_dimensions
|
int
|
Number of latent dimensions. Default is 1. |
1
|
center
|
bool
|
Whether to subtract column means before fitting. Default True. |
True
|
Example
import numpy as np rng = np.random.default_rng(0) X1 = rng.standard_normal((50, 10)) X2 = rng.standard_normal((50, 8)) model = PLS(latent_dimensions=2).fit([X1, X2]) scores = model.transform([X1, X2])
Source code in cca_zoo/linear/_pls.py
fit ¶
Fit the PLS model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
views
|
list[ArrayLike]
|
List of exactly two arrays, each (n_samples, n_features_i). |
required |
y
|
None
|
Ignored. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
self |
PLS
|
Fitted estimator. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the number of views is not exactly 2. |
ValueError
|
If views have inconsistent numbers of samples. |
Example
import numpy as np rng = np.random.default_rng(0) X1 = rng.standard_normal((50, 10)) X2 = rng.standard_normal((50, 8)) model = PLS(latent_dimensions=2).fit([X1, X2])
Source code in cca_zoo/linear/_pls.py
Multiview methods¶
MCCA ¶
MCCA(
latent_dimensions: int = 1,
center: bool = True,
c: float | list[float] = 0.0,
pca: bool = True,
eps: float = 1e-06,
)
Bases: BaseModel
Multiset Canonical Correlation Analysis.
Finds linear projections of multiple (>=2) views that maximise the sum of
pairwise cross-view covariances subject to within-view variance constraints.
A ridge regularisation parameter c controls the trade-off between
correlation and variance explained.
The primal objective is:
This is solved as a generalised eigenvalue problem:
where \(A\) is the between-view block covariance matrix and \(B\) is the block-diagonal regularised within-view covariance matrix.
When pca=True (default), each view is first reduced to its principal
components, which makes the problem numerically stable for
high-dimensional data and allows an efficient closed-form \(B\).
References
Kettenring, J. R. (1971). Canonical analysis of several sets of variables. Biometrika, 58(3), 433–451.
Vinod, H. D. (1976). Canonical ridge and econometrics of joint production. Journal of Econometrics, 4(2), 147–166.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
latent_dimensions
|
int
|
Number of latent dimensions. Default is 1. |
1
|
center
|
bool
|
Whether to subtract column means before fitting. Default True. |
True
|
c
|
float | list[float]
|
Ridge regularisation parameter(s). Either a single float applied
to all views or a list of per-view floats in |
0.0
|
pca
|
bool
|
Whether to apply full PCA whitening as a pre-processing step before solving the eigenvalue problem. Highly recommended for high-dimensional data. Default is True. |
True
|
eps
|
float
|
Small constant added to the eigenvalues of B to ensure positive definiteness. Default is 1e-6. |
1e-06
|
Example
import numpy as np rng = np.random.default_rng(0) X1 = rng.standard_normal((50, 10)) X2 = rng.standard_normal((50, 8)) X3 = rng.standard_normal((50, 6)) model = MCCA(latent_dimensions=2).fit([X1, X2, X3]) scores = model.transform([X1, X2, X3])
Source code in cca_zoo/linear/_mcca.py
fit ¶
Fit the MCCA model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
views
|
list[ArrayLike]
|
List of arrays, each (n_samples, n_features_i). |
required |
y
|
None
|
Ignored. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
self |
MCCA
|
Fitted estimator. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If fewer than 2 views are provided. |
ValueError
|
If views have inconsistent numbers of samples. |
Source code in cca_zoo/linear/_mcca.py
GCCA ¶
GCCA(
latent_dimensions: int = 1,
center: bool = True,
c: float | list[float] = 0.0,
view_weights: list[float] | None = None,
eps: float = 1e-06,
)
Bases: BaseModel
Generalised Canonical Correlation Analysis.
Finds linear projections of multiple (>=2) views that maximise their joint correlation with a shared auxiliary latent vector:
The solution is obtained by constructing the weighted projection matrix:
and computing its top-k eigenvectors \(V\), then recovering the per-view weights as \(\mathbf{w}_i = X_i^+ V\).
References
Tenenhaus, A., & Tenenhaus, M. (2011). Regularized generalized canonical correlation analysis. Psychometrika, 76(2), 257–284.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
latent_dimensions
|
int
|
Number of latent dimensions. Default is 1. |
1
|
center
|
bool
|
Whether to subtract column means before fitting. Default True. |
True
|
c
|
float | list[float]
|
Ridge regularisation parameter(s) in |
0.0
|
view_weights
|
list[float] | None
|
Per-view weights \(\mu_i\) in the GCCA objective. Default is equal weights (1 for all views). |
None
|
eps
|
float
|
Regularisation floor for within-view matrices. Default is 1e-6. |
1e-06
|
Example
import numpy as np rng = np.random.default_rng(0) X1 = rng.standard_normal((50, 10)) X2 = rng.standard_normal((50, 8)) X3 = rng.standard_normal((50, 6)) model = GCCA(latent_dimensions=2).fit([X1, X2, X3]) scores = model.transform([X1, X2, X3])
Source code in cca_zoo/linear/_gcca.py
fit ¶
Fit the GCCA model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
views
|
list[ArrayLike]
|
List of arrays, each (n_samples, n_features_i). |
required |
y
|
None
|
Ignored. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
self |
GCCA
|
Fitted estimator. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If fewer than 2 views are provided. |
ValueError
|
If views have inconsistent numbers of samples. |
Source code in cca_zoo/linear/_gcca.py
TCCA ¶
TCCA(
latent_dimensions: int = 1,
center: bool = True,
c: float | list[float] = 0.0,
eps: float = 1e-06,
random_state: int | None = None,
)
Bases: BaseModel
Tensor Canonical Correlation Analysis.
Extends CCA to more than two views by exploiting higher-order cross-view correlations via a tensor product structure. The method constructs the order-M cross-moment tensor:
where \(\tilde{X}_j = X_j \Sigma_j^{-1/2}\) are the whitened views, and then decomposes \(\mathcal{M}\) using PARAFAC to recover the canonical directions.
References
Kim, T.-K., Wong, S.-F., & Cipolla, R. (2007). Tensor canonical correlation analysis for action classification. CVPR 2007. IEEE.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
latent_dimensions
|
int
|
Number of latent dimensions. Default is 1. |
1
|
center
|
bool
|
Whether to subtract column means before fitting. Default True. |
True
|
c
|
float | list[float]
|
Ridge regularisation in |
0.0
|
eps
|
float
|
Regularisation floor for within-view covariance matrices. |
1e-06
|
random_state
|
int | None
|
Seed for reproducibility (passed to PARAFAC). |
None
|
Example
import numpy as np rng = np.random.default_rng(0) X1 = rng.standard_normal((50, 5)) X2 = rng.standard_normal((50, 5)) X3 = rng.standard_normal((50, 5)) model = TCCA(latent_dimensions=2, random_state=0).fit([X1, X2, X3]) scores = model.transform([X1, X2, X3])
Source code in cca_zoo/linear/_tcca.py
fit ¶
Fit the TCCA model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
views
|
list[ArrayLike]
|
List of arrays, each (n_samples, n_features_i). |
required |
y
|
None
|
Ignored. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
self |
TCCA
|
Fitted estimator. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If fewer than 2 views are provided. |
ValueError
|
If views have inconsistent numbers of samples. |
Source code in cca_zoo/linear/_tcca.py
Confound-adjusted / structured methods¶
PartialCCA ¶
PartialCCA(
latent_dimensions: int = 1,
center: bool = True,
c: float | list[float] = 0.0,
eps: float = 1e-06,
)
Bases: MCCA
Partial Canonical Correlation Analysis.
Extends CCA to account for confounding variables partials that may
drive the correlation between views. Each view is first deconfounded by
regressing out partials via least squares, and (ridge-regularised)
CCA is then applied to the residuals, subject to the additional
constraint that canonical weights are orthogonal to the confounds:
References
Rao, B. R. (1969). Partial canonical correlations. Trabajos de Estadistica y de Investigacion Operativa, 20(2-3), 211-219.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
latent_dimensions
|
int
|
Number of latent dimensions. Default is 1. |
1
|
center
|
bool
|
Whether to subtract column means before fitting. Default True. |
True
|
c
|
float | list[float]
|
Ridge regularisation parameter(s) applied to the deconfounded views. Either a scalar or a per-view list. Default is 0. |
0.0
|
eps
|
float
|
Small constant added to the eigenvalues of B to ensure positive definiteness. Default is 1e-6. |
1e-06
|
Example
import numpy as np rng = np.random.default_rng(0) X1 = rng.standard_normal((50, 10)) X2 = rng.standard_normal((50, 8)) Z = rng.standard_normal((50, 3)) model = PartialCCA(latent_dimensions=2).fit([X1, X2], partials=Z) scores = model.transform([X1, X2], partials=Z)
Source code in cca_zoo/linear/_partialcca.py
fit ¶
Fit the Partial CCA model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
views
|
list[ArrayLike]
|
List of arrays, each (n_samples, n_features_i). |
required |
y
|
None
|
Ignored. |
None
|
partials
|
ArrayLike | None
|
Confound array of shape (n_samples, n_confounds) to regress out of each view before fitting CCA. Required. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
self |
PartialCCA
|
Fitted estimator. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Source code in cca_zoo/linear/_partialcca.py
transform ¶
Project views into the latent space, optionally removing confounds.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
views
|
list[ArrayLike]
|
List of arrays, each (n_samples, n_features_i). |
required |
partials
|
ArrayLike | None
|
Confound array matching the one used at fit time. If
omitted, no deconfounding is applied (falls back to a plain
linear projection), which keeps |
None
|
Returns:
| Type | Description |
|---|---|
list[ndarray]
|
List of arrays, each (n_samples, latent_dimensions). |
Source code in cca_zoo/linear/_partialcca.py
fit_transform ¶
fit_transform(
views: list[ArrayLike],
y: None = None,
partials: ArrayLike | None = None,
) -> list[np.ndarray]
Fit and then transform the training data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
views
|
list[ArrayLike]
|
List of arrays, each (n_samples, n_features_i). |
required |
y
|
None
|
Ignored. |
None
|
partials
|
ArrayLike | None
|
Confound array, passed through to both |
None
|
Returns:
| Type | Description |
|---|---|
list[ndarray]
|
List of arrays, each (n_samples, latent_dimensions). |
Source code in cca_zoo/linear/_partialcca.py
GRCCA ¶
GRCCA(
latent_dimensions: int = 1,
center: bool = True,
c: float | list[float] = 0.0,
mu: float | list[float] = 0.0,
eps: float = 1e-06,
)
Bases: MCCA
Group Regularised Canonical Correlation Analysis.
Extends :class:MCCA with structured ridge regularisation that shrinks
within-group feature weights toward a shared group-level effect. Each
view's features are partitioned into groups via feature_groups; the
per-view c parameter controls shrinkage of within-group deviations
and mu controls the weighting of the group-level effect.
Each view is internally augmented with group-mean features before
solving the generalised eigenvalue problem, then the resulting weights
are algebraically collapsed back to the original feature space, so
transform operates directly on the un-augmented views.
References
Tuzhilina, E., Tozzi, L., & Hastie, T. (2021). Canonical correlation analysis in high dimensions with structured regularization. Statistical Modelling.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
latent_dimensions
|
int
|
Number of latent dimensions. Default is 1. |
1
|
center
|
bool
|
Whether to subtract column means before fitting. Default True. |
True
|
c
|
float | list[float]
|
Ridge regularisation parameter(s) controlling within-group
shrinkage. Either a scalar applied to all views or a per-view
list, each in |
0.0
|
mu
|
float | list[float]
|
Regularisation parameter(s) controlling the group-level effect scale. Either a scalar or a per-view list. Default is 0. |
0.0
|
eps
|
float
|
Small constant added to the eigenvalues of B to ensure positive definiteness. Default is 1e-6. |
1e-06
|
Example
import numpy as np rng = np.random.default_rng(0) X1 = rng.standard_normal((50, 10)) X2 = rng.standard_normal((50, 8)) groups1 = rng.integers(0, 3, size=10) groups2 = rng.integers(0, 3, size=8) model = GRCCA(latent_dimensions=2, c=0.5).fit( ... [X1, X2], feature_groups=[groups1, groups2] ... ) scores = model.transform([X1, X2])
Source code in cca_zoo/linear/_grcca.py
fit ¶
fit(
views: list[ArrayLike],
y: None = None,
feature_groups: list[ndarray] | None = None,
) -> GRCCA
Fit the GRCCA model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
views
|
list[ArrayLike]
|
List of arrays, each (n_samples, n_features_i). |
required |
y
|
None
|
Ignored. |
None
|
feature_groups
|
list[ndarray] | None
|
List of integer group-label arrays, one per
view, each of shape (n_features_i,). Required for
meaningful grouping whenever the corresponding per-view
|
None
|
Returns:
| Name | Type | Description |
|---|---|---|
self |
GRCCA
|
Fitted estimator. |
Source code in cca_zoo/linear/_grcca.py
Reduced-rank regression methods¶
CCAR3 ¶
CCAR3(
latent_dimensions: int = 1,
center: bool = True,
lambda_: float = 0.0,
highdim: bool = True,
ledoit_wolf: bool = True,
rho: float = 1.0,
max_iter: int = 10000,
tol: float = 0.0001,
eps: float = 1e-08,
)
Bases: BaseModel
Canonical Correlation Analysis via Reduced Rank Regression.
Recasts two-view CCA as a reduced-rank regression: Y is first
whitened by its (optionally Ledoit-Wolf shrunk) covariance,
and a coefficient matrix \(B\) relating \(X\) to \(\tilde{Y}\) is estimated.
In the low-dimensional regime (highdim=False) this has the closed
form \(B = \Sigma_X^{-1} X^\top \tilde{Y} / n\) (an ordinary reduced-rank
regression, distinct from the classical CCA eigenproblem — the two
agree only when \(\Sigma_X\) is close to isotropic). In the
high-dimensional regime (highdim=True, the default), \(B\) is
instead estimated by a row-wise group-lasso-penalised regression,
solved by ADMM:
which drives whole rows of \(B\) (whole \(X\) features) to zero, giving a
sparse-in-\(X\) solution well-suited to \(p \gg n\). The rank-
latent_dimensions SVD of \(\hat{B}\) gives the canonical directions,
which are then whitened so that the canonical variates have unit
variance, sign-aligned to positive correlation, and sorted in
descending order.
Because the penalty acts on rows of \(B\), sparsity is induced only in
\(X\); \(Y\) is handled densely via its inverse-square-root covariance.
Swap the order of views to regularise the other view instead.
This is a from-scratch NumPy port of the reference R implementation,
ccar3; cross-validation
utilities and the CVXR/rrpack solver backends are out of scope here —
use GridSearchCV from cca_zoo.model_selection to select lambda_
as for any other estimator.
References
Donnat, C., & Tuzhilina, E. (2024). Canonical Correlation Analysis as Reduced Rank Regression in High Dimensions. arXiv:2405.19539.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
latent_dimensions
|
int
|
Number of latent dimensions. Default is 1. |
1
|
center
|
bool
|
Whether to subtract column means before fitting. Default True. |
True
|
lambda_
|
float
|
Row-group-lasso regularisation strength used when
|
0.0
|
highdim
|
bool
|
Whether to estimate the reduced-rank coefficient with the
ADMM-solved group-lasso penalty (default, needed when |
True
|
ledoit_wolf
|
bool
|
Whether to shrink the |
True
|
rho
|
float
|
ADMM step-size parameter. Default 1.0. |
1.0
|
max_iter
|
int
|
Maximum number of ADMM iterations. Default 10_000. |
10000
|
tol
|
float
|
ADMM convergence tolerance on the primal/dual residuals. Default 1e-4. |
0.0001
|
eps
|
float
|
Small constant added to covariance matrices before inversion, for numerical stability. Default 1e-8. |
1e-08
|
Example
import numpy as np rng = np.random.default_rng(0) X1 = rng.standard_normal((50, 10)) X2 = rng.standard_normal((50, 8)) model = CCAR3(latent_dimensions=2, highdim=False).fit([X1, X2]) scores = model.transform([X1, X2])
Source code in cca_zoo/linear/_ccar3.py
fit ¶
Fit the CCAR3 model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
views
|
list[ArrayLike]
|
List of exactly two arrays, each (n_samples, n_features_i). |
required |
y
|
None
|
Ignored. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
self |
CCAR3
|
Fitted estimator. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the number of views is not exactly 2. |
ValueError
|
If views have inconsistent numbers of samples. |
Source code in cca_zoo/linear/_ccar3.py
Gradient-descent methods¶
PLS_EY ¶
PLS_EY(
latent_dimensions: int = 1,
center: bool = True,
learning_rate: float = 0.01,
max_iter: int = 1000,
batch_size: int | None = None,
tol: float = 1e-06,
momentum: float = 0.9,
random_state: int | None = None,
)
Bases: CCA_EY
Stochastic Eckart-Young PLS for large-scale data.
This is equivalent to :class:~cca_zoo.linear.gradient.CCA_EY with
c=1: the reward excludes the \(i = j\) terms that CCA_EY's
(\(c=0\)) reward includes, and the penalty is purely
\(\operatorname{tr}(BB)\) on the weight Gram matrix \(B\), which
drives the weights towards (approximate) orthonormality at the optimum
on its own — no manifold projection step, and no upfront whitening.
Suitable for high-dimensional or streaming data where forming the full (p x p) cross-covariance matrix is too expensive.
Initial weights have exactly orthonormal columns (unit-norm, mutually
orthogonal) before any gradient step, matching the shape of this loss's
own penalty on \(B\) — unlike :class:~cca_zoo.linear.gradient.CCA_EY's
own data-informed default, which instead orthonormalises the initial
projections (see :func:cca_zoo._utils._ey.random_orthonormal_weights
vs. :func:cca_zoo._utils._ey.cheap_orthonormal_projection_weights).
References
Chapman, J., Wells, L., & Lawry Aguila, A. (2024). Unconstrained Stochastic CCA: Unifying Multiview and Self-Supervised Learning. arXiv:2310.01012.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
latent_dimensions
|
int
|
Number of latent dimensions. Default is 1. |
1
|
center
|
bool
|
Whether to subtract column means. Default True. |
True
|
learning_rate
|
float
|
Gradient step size. Default is 1e-2. |
0.01
|
max_iter
|
int
|
Number of gradient steps. Default is 1000. |
1000
|
batch_size
|
int | None
|
Mini-batch size. |
None
|
tol
|
float
|
Convergence tolerance on the objective change. Default is 1e-6. |
1e-06
|
momentum
|
float
|
Momentum coefficient in |
0.9
|
random_state
|
int | None
|
Seed for reproducibility. |
None
|
Example
import numpy as np rng = np.random.default_rng(0) X1 = rng.standard_normal((200, 500)) X2 = rng.standard_normal((200, 400)) model = PLS_EY(latent_dimensions=4, batch_size=64, random_state=0) model = model.fit([X1, X2])
Source code in cca_zoo/linear/gradient/_pls_ey.py
fit ¶
Fit PLS_EY by mini-batch momentum gradient descent.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
views
|
list[ArrayLike]
|
List of arrays, each (n_samples, n_features_i). |
required |
y
|
None
|
Ignored. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
self |
PLS_EY
|
Fitted estimator. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If fewer than 2 views are provided. |
ValueError
|
If views have inconsistent numbers of samples. |
Source code in cca_zoo/linear/gradient/_pls_ey.py
CCA_EY ¶
CCA_EY(
latent_dimensions: int = 1,
center: bool = True,
c: float = 0.0,
learning_rate: float = 0.01,
max_iter: int = 1000,
batch_size: int | None = None,
tol: float = 1e-06,
momentum: float = 0.9,
random_state: int | None = None,
)
Bases: BaseGradientModel
Eckart-Young CCA for large-scale data, ridge-blended with PLS_EY.
Optimises the unconstrained Eckart-Young (EY) objective by mini-batch
momentum gradient descent directly on the raw (centred) views, with no
manifold projection step and no upfront whitening: unlike classical CCA,
which whitens each view before finding the correlated directions, the EY
reformulation folds the orthonormalising pressure into the loss itself,
so a full-batch preprocessing pass over the data is never needed. This
matches how the same underlying loss is used, unwhitened, by
:class:~cca_zoo.linear.gradient.PLS_EY, :class:~cca_zoo.tree.TreeCCA,
and :class:~cca_zoo.deep.DCCA_EY.
For embeddings \(Z_i = X_i W_i\), let \(C\) and \(V\) be the mean
pairwise cross-covariance and mean auto-covariance across views (see
:func:cca_zoo._utils._ey.ey_cross_covariance), and
\(B = \frac{1}{M}\sum_i W_i^\top W_i\) the mean weight Gram matrix
(see :func:cca_zoo._utils._ey.weight_gram_mean). c blends the
within-view normalisation between the data's own auto-covariance and
the identity (in weight space, \(W_i^\top I W_i = W_i^\top W_i\)) —
exactly the canonical-ridge blend \((1-c)X^\top X + cI\) already used by
:class:~cca_zoo.linear.rCCA, translated into this unconstrained,
stochastic setting:
c=0 recovers plain (unregularised) CCA_EY exactly; c=1
recovers :class:~cca_zoo.linear.gradient.PLS_EY's loss exactly (its
reward excludes the \(i=j\) terms that \(\mathcal{L}_{EY}(0)\)
includes, and its penalty is purely \(\operatorname{tr}(BB)\)) —
both endpoints, and the gradient at intermediate \(c\), are verified
against finite differences and against PLS_EY's own independently
verified gradient. This objective has the canonical directions as a
stationary point without requiring an explicit orthonormality
constraint, unlike a plain squared-projection-distance loss.
Note
Unlike the exact, closed-form :class:~cca_zoo.linear.rCCA (where
c=0 is always numerically safe), gradient descent on the raw,
unregularised (\(c=0\)) objective can diverge to nan when a
mini-batch's samples don't outnumber the number of features by a
healthy margin — e.g. n_features approaching or exceeding
batch_size — since nothing then bounds the weights in the
data's near-null directions. If you see nan weights, increase
c (a small value like 0.1-0.3 is usually enough) or
batch_size rather than assuming the model doesn't apply to your
data. (Initial weights give exactly unit-variance, uncorrelated
projections on one mini-batch — see
:func:cca_zoo._utils._ey.cheap_orthonormal_projection_weights — a
cheap stand-in for classical CCA's full whitening step and the
natural match for this loss's own fixed point; empirically this
does not postpone the divergence above, since every later
mini-batch is an independent fresh draw, so c/batch_size
remain the actual remedy.)
References
Chapman, J., Wells, L., & Lawry Aguila, A. (2024). Unconstrained Stochastic CCA: Unifying Multiview and Self-Supervised Learning. arXiv:2310.01012.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
latent_dimensions
|
int
|
Number of latent dimensions. Default is 1. |
1
|
center
|
bool
|
Whether to subtract column means. Default True. |
True
|
c
|
float
|
Ridge blend in |
0.0
|
learning_rate
|
float
|
Gradient step size. Default is 1e-2. |
0.01
|
max_iter
|
int
|
Number of gradient steps. Default is 1000. |
1000
|
batch_size
|
int | None
|
Mini-batch size. |
None
|
tol
|
float
|
Convergence tolerance. Default is 1e-6. |
1e-06
|
momentum
|
float
|
Momentum coefficient in |
0.9
|
random_state
|
int | None
|
Seed for reproducibility. |
None
|
Example
import numpy as np rng = np.random.default_rng(0) X1 = rng.standard_normal((5000, 200)) X2 = rng.standard_normal((5000, 150)) model = CCA_EY(latent_dimensions=4, batch_size=128, random_state=0) model = model.fit([X1, X2])
Source code in cca_zoo/linear/gradient/_cca_ey.py
fit ¶
Fit CCA_EY by mini-batch momentum gradient descent.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
views
|
list[ArrayLike]
|
List of arrays, each (n_samples, n_features_i). |
required |
y
|
None
|
Ignored. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
self |
CCA_EY
|
Fitted estimator. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If fewer than 2 views are provided. |
ValueError
|
If views have inconsistent numbers of samples. |
Source code in cca_zoo/linear/gradient/_cca_ey.py
MCCA_EY ¶
MCCA_EY(
latent_dimensions: int = 1,
center: bool = True,
c: float = 0.0,
learning_rate: float = 0.01,
max_iter: int = 1000,
batch_size: int | None = None,
tol: float = 1e-06,
momentum: float = 0.9,
random_state: int | None = None,
)
Bases: CCA_EY
Eckart-Young multiview CCA for large-scale data (>=2 views).
Identical to :class:CCA_EY; the shared Eckart-Young loss and its
gradient (see :mod:cca_zoo._utils._ey) are already defined for an
arbitrary number of views, so no multiview-specific logic is needed here.
References
Chapman, J., Wells, L., & Lawry Aguila, A. (2024). Unconstrained Stochastic CCA: Unifying Multiview and Self-Supervised Learning. arXiv:2310.01012.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
latent_dimensions
|
int
|
Number of latent dimensions. Default is 1. |
1
|
center
|
bool
|
Whether to subtract column means. Default True. |
True
|
c
|
float
|
Ridge blend in |
0.0
|
learning_rate
|
float
|
Gradient step size. Default is 1e-2. |
0.01
|
max_iter
|
int
|
Number of gradient steps. Default is 1000. |
1000
|
batch_size
|
int | None
|
Mini-batch size. |
None
|
tol
|
float
|
Convergence tolerance. Default is 1e-6. |
1e-06
|
momentum
|
float
|
Momentum coefficient in |
0.9
|
random_state
|
int | None
|
Seed for reproducibility. |
None
|
Example
import numpy as np rng = np.random.default_rng(0) X1 = rng.standard_normal((5000, 200)) X2 = rng.standard_normal((5000, 150)) X3 = rng.standard_normal((5000, 100)) model = MCCA_EY(latent_dimensions=4, batch_size=128, random_state=0) model = model.fit([X1, X2, X3])
Source code in cca_zoo/linear/gradient/_cca_ey.py
fit ¶
Fit MCCA_EY for 2 or more views.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
views
|
list[ArrayLike]
|
List of arrays, each (n_samples, n_features_i). |
required |
y
|
None
|
Ignored. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
self |
MCCA_EY
|
Fitted estimator. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If fewer than 2 views are provided. |
ValueError
|
If views have inconsistent numbers of samples. |
Source code in cca_zoo/linear/gradient/_mcca_ey.py
Sparse / iterative methods¶
PLS_ALS ¶
PLS_ALS(
latent_dimensions: int = 1,
center: bool = True,
max_iter: int = 500,
tol: float = 1e-06,
random_state: int | None = None,
)
Bases: _BaseIterative
Alternating Least Squares variant of Partial Least Squares.
Maximises the sum of cross-view covariances using simple power-iteration updates, without regularisation:
where \(\bar{\mathbf{s}}_{\neg i}\) is the normalised sum of projected scores from all views except \(i\). This is the multiset generalisation of the NIPALS alternating power iteration.
References
Wold, H. (1975). Soft modelling by latent variables: the nonlinear iterative partial least squares (NIPALS) approach. Perspectives in Probability and Statistics, 117-142.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
latent_dimensions
|
int
|
Number of latent dimensions. Default is 1. |
1
|
center
|
bool
|
Whether to subtract column means. Default True. |
True
|
max_iter
|
int
|
Maximum ALS iterations per dimension. Default is 500. |
500
|
tol
|
float
|
Convergence tolerance. Default is 1e-6. |
1e-06
|
random_state
|
int | None
|
Seed for reproducibility. |
None
|
Example
import numpy as np rng = np.random.default_rng(0) X1 = rng.standard_normal((50, 10)) X2 = rng.standard_normal((50, 8)) model = PLS_ALS(latent_dimensions=2, random_state=0).fit([X1, X2])
Source code in cca_zoo/linear/_iterative.py
SCCA_PMD ¶
SCCA_PMD(
latent_dimensions: int = 1,
center: bool = True,
tau: float | list[float] = 1.0,
max_iter: int = 500,
tol: float = 1e-06,
random_state: int | None = None,
)
Bases: _BaseIterative
Sparse CCA via Penalized Matrix Decomposition.
Maximises the cross-view covariance subject to L1 norm constraints on each weight vector:
The update for each view uses bisection to find the soft-threshold that satisfies the L1 constraint exactly.
References
Witten, D. M., Tibshirani, R., & Hastie, T. (2009). A penalized matrix decomposition, with applications to sparse principal components and canonical correlation analysis. Biostatistics, 10(3), 515–534.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
latent_dimensions
|
int
|
Number of latent dimensions. Default is 1. |
1
|
center
|
bool
|
Whether to subtract column means. Default True. |
True
|
tau
|
float | list[float]
|
L1 bound scaling factor(s) in |
1.0
|
max_iter
|
int
|
Maximum ALS iterations. Default is 500. |
500
|
tol
|
float
|
Convergence tolerance. Default is 1e-6. |
1e-06
|
random_state
|
int | None
|
Seed for reproducibility. |
None
|
Example
import numpy as np rng = np.random.default_rng(0) X1 = rng.standard_normal((50, 10)) X2 = rng.standard_normal((50, 8)) model = SCCA_PMD(tau=0.5, random_state=0).fit([X1, X2])
Source code in cca_zoo/linear/_iterative.py
fit ¶
Fit the SCCA_PMD model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
views
|
list[ArrayLike]
|
List of arrays, each (n_samples, n_features_i). |
required |
y
|
None
|
Ignored. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
self |
SCCA_PMD
|
Fitted estimator. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If fewer than 2 views are provided. |
Source code in cca_zoo/linear/_iterative.py
SCCA_ADMM ¶
SCCA_ADMM(
latent_dimensions: int = 1,
center: bool = True,
tau: float | list[float] = 0.1,
mu: float = 1.0,
max_iter: int = 500,
tol: float = 1e-06,
random_state: int | None = None,
)
Bases: _BaseIterative
Sparse CCA via Alternating Direction Method of Multipliers.
Solves the sparse CCA problem using ADMM to enforce both the L1 sparsity constraint on weight vectors and the unit-norm constraint on the projected scores simultaneously. For view \(i\), each outer iteration performs:
where \(\bar{\mathbf{s}}_{\neg i}\) is the summed projected score from all other views, \(\mathcal{S}_\lambda\) is the elementwise soft-threshold operator, \(\Pi_{\|\cdot\|_2 \le 1}\) projects onto the unit ball, \(\mathbf{u}_i\) is the scaled dual variable, and \(\gamma_i = \bigl(\|X_i^\top X_i\| / n + \mu\bigr)^{-1}\).
References
Suo, X., Mineiro, P., & Anandkumar, A. (2017). Sparse canonical correlation analysis. arXiv:1705.10865.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
latent_dimensions
|
int
|
Number of latent dimensions. Default is 1. |
1
|
center
|
bool
|
Whether to subtract column means. Default True. |
True
|
tau
|
float | list[float]
|
L1 regularisation weight(s). Default is 0.1. |
0.1
|
mu
|
float
|
ADMM penalty parameter (step size). Default is 1.0. |
1.0
|
max_iter
|
int
|
Maximum outer iterations. Default is 500. |
500
|
tol
|
float
|
Convergence tolerance. Default is 1e-6. |
1e-06
|
random_state
|
int | None
|
Seed for reproducibility. |
None
|
Example
import numpy as np rng = np.random.default_rng(0) X1 = rng.standard_normal((50, 10)) X2 = rng.standard_normal((50, 8)) model = SCCA_ADMM(tau=0.1, random_state=0).fit([X1, X2])
Source code in cca_zoo/linear/_iterative.py
SCCA_IPLS ¶
SCCA_IPLS(
latent_dimensions: int = 1,
center: bool = True,
alpha: float | list[float] = 0.0,
l1_ratio: float | list[float] = 1.0,
max_iter: int = 500,
tol: float = 1e-06,
random_state: int | None = None,
)
Bases: _BaseIterative
Iterative PLS with elastic net penalty on weight vectors.
Alternates between penalised regression sub-problems. For view \(i\):
followed by a normalisation step to enforce unit variance of the score.
References
Mai, Q., & Zhang, X. (2019). An iterative penalized least squares approach to sparse canonical correlation analysis. Biometrics, 75(3), 734–744.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
latent_dimensions
|
int
|
Number of latent dimensions. Default is 1. |
1
|
center
|
bool
|
Whether to subtract column means. Default True. |
True
|
alpha
|
float | list[float]
|
Elastic net penalty strength(s). Default is 0. |
0.0
|
l1_ratio
|
float | list[float]
|
Ratio of L1 to total penalty. 1 = lasso, 0 = ridge. Default is 1. |
1.0
|
max_iter
|
int
|
Maximum ALS iterations. Default is 500. |
500
|
tol
|
float
|
Convergence tolerance. Default is 1e-6. |
1e-06
|
random_state
|
int | None
|
Seed for reproducibility. |
None
|
Example
import numpy as np rng = np.random.default_rng(0) X1 = rng.standard_normal((50, 10)) X2 = rng.standard_normal((50, 8)) model = SCCA_IPLS(alpha=0.1, random_state=0).fit([X1, X2])
Source code in cca_zoo/linear/_iterative.py
SCCA_Span ¶
SCCA_Span(
latent_dimensions: int = 1,
center: bool = True,
span: int | list[int] | None = None,
max_iter: int = 500,
tol: float = 1e-06,
random_state: int | None = None,
)
Bases: _BaseIterative
SpanCCA — sparse CCA via truncated power iteration.
Solves sparse CCA by a sparse power iteration where each weight update
retains only the span entries with the largest absolute values.
References
Asteris, M., Khanna, R., Kyrillidis, A., & Dimakis, A. G. (2016). Bilinear approaches for online learning over large feature spaces. NeurIPS 2016. (SpanCCA algorithm).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
latent_dimensions
|
int
|
Number of latent dimensions. Default is 1. |
1
|
center
|
bool
|
Whether to subtract column means. Default True. |
True
|
span
|
int | list[int] | None
|
Number of non-zero entries to retain per view. Either a single int or a list. Default is None (keep all — no sparsity). |
None
|
max_iter
|
int
|
Maximum ALS iterations. Default is 500. |
500
|
tol
|
float
|
Convergence tolerance. Default is 1e-6. |
1e-06
|
random_state
|
int | None
|
Seed for reproducibility. |
None
|
Example
import numpy as np rng = np.random.default_rng(0) X1 = rng.standard_normal((50, 10)) X2 = rng.standard_normal((50, 8)) model = SCCA_Span(span=5, random_state=0).fit([X1, X2])
Source code in cca_zoo/linear/_iterative.py
ElasticCCA ¶
ElasticCCA(
latent_dimensions: int = 1,
center: bool = True,
alpha: float | list[float] = 0.0,
l1_ratio: float | list[float] = 0.5,
max_iter: int = 500,
tol: float = 1e-06,
random_state: int | None = None,
)
Bases: _BaseIterative
Elastic net regularised CCA.
Alternates between elastic net regression sub-problems, regressing each view's score against the sum of all other views' scores:
where \(\mathbf{s}_{\text{all}} = \sum_j X_j \mathbf{w}_j / \|\cdot\|\).
References
Waaijenborg, S., de Witt Hamer, P. C. V., & Zwinderman, A. H. (2008). Quantifying the association between gene expressions and DNA-markers by penalized canonical correlation analysis. Statistical Applications in Genetics and Molecular Biology, 7(1).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
latent_dimensions
|
int
|
Number of latent dimensions. Default is 1. |
1
|
center
|
bool
|
Whether to subtract column means. Default True. |
True
|
alpha
|
float | list[float]
|
Elastic net regularisation strength. Default is 0. |
0.0
|
l1_ratio
|
float | list[float]
|
L1 / total penalty ratio. Default is 0.5. |
0.5
|
max_iter
|
int
|
Maximum ALS iterations. Default is 500. |
500
|
tol
|
float
|
Convergence tolerance. Default is 1e-6. |
1e-06
|
random_state
|
int | None
|
Seed for reproducibility. |
None
|
Example
import numpy as np rng = np.random.default_rng(0) X1 = rng.standard_normal((50, 10)) X2 = rng.standard_normal((50, 8)) model = ElasticCCA(alpha=0.1, l1_ratio=0.5, random_state=0).fit([X1, X2])
Source code in cca_zoo/linear/_iterative.py
ParkhomenkoCCA ¶
ParkhomenkoCCA(
latent_dimensions: int = 1,
center: bool = True,
tau: float | list[float] = 0.1,
max_iter: int = 500,
tol: float = 1e-06,
random_state: int | None = None,
)
Bases: _BaseIterative
Sparse CCA via soft-thresholding power iteration (Parkhomenko 2009).
Uses a fixed soft-threshold \(\tau_i\) rather than the adaptive
bisection search of :class:SCCA_PMD:
where \(S_\tau\) is the element-wise soft-threshold operator.
References
Parkhomenko, E., Tritchler, D., & Beyene, J. (2009). Sparse canonical correlation analysis with application to genomic data integration. Statistical Applications in Genetics and Molecular Biology, 8(1).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
latent_dimensions
|
int
|
Number of latent dimensions. Default is 1. |
1
|
center
|
bool
|
Whether to subtract column means. Default True. |
True
|
tau
|
float | list[float]
|
Soft-threshold parameter(s). Default is 0.1. |
0.1
|
max_iter
|
int
|
Maximum ALS iterations. Default is 500. |
500
|
tol
|
float
|
Convergence tolerance. Default is 1e-6. |
1e-06
|
random_state
|
int | None
|
Seed for reproducibility. |
None
|
Example
import numpy as np rng = np.random.default_rng(0) X1 = rng.standard_normal((50, 10)) X2 = rng.standard_normal((50, 8)) model = ParkhomenkoCCA(tau=0.1, random_state=0).fit([X1, X2])