cca_zoo.gp¶
Gaussian-process (GP) nonlinear CCA methods, fit in closed form by one generalized eigendecomposition. Built entirely on scikit-learn's own
GaussianProcessRegressor/RBF/ConstantKernel/KernelCenterer — no optional dependency
required.
GaussianProcessCCA ¶
GaussianProcessCCA(
n_components: int = 1,
*,
center: bool = True,
kernel: Kernel | list[Kernel | None] | None = None,
alpha: float | list[float] = 0.01,
n_inducing: int | list[int | None] | None = None,
random_state: int | None = None,
)
Bases: BaseModel
Nonlinear CCA with Gaussian-process encoders.
Each view's encoder is \(f_i(x) = k(x, U_i)^\top B_i\) for a kernel \(k\) over
the whole feature vector and inducing points \(U_i\), so it can represent
within-view interactions. Every view's \(B_i\) minimises the EY loss
(:mod:cca_zoo._utils._ey) plus the RKHS-norm penalty
\(\tfrac12 \alpha_i \operatorname{tr}(B_i^\top K_i B_i)\). On the Nyström
features of the inducing points the penalty is a ridge, and the global
minimiser is a generalized eigenproblem, solved in closed form. Fitting
costs \(O(n m^2 + m^3)\) for \(m\) inducing points. Kernel hyperparameters are
fixed; tune them by cross-validation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n_components
|
int
|
Number of latent dimensions. Default is 1. |
1
|
center
|
bool
|
Whether to centre each view. Default is True. |
True
|
kernel
|
Kernel | list[Kernel | None] | None
|
A kernel, cloned per view, or one per view; None uses
|
None
|
alpha
|
float | list[float]
|
RKHS-norm penalty, also the noise level of the posterior variance. Per-view. Default is 0.01. |
0.01
|
n_inducing
|
int | list[int | None] | None
|
Number of inducing points; None, or at least
|
None
|
random_state
|
int | None
|
Seed for the inducing points. Default is None. |
None
|
Attributes:
| Name | Type | Description |
|---|---|---|
encoders_ |
Fitted per-view encoders, with |
References
Chapman, J., Wang, H.-T., Wells, L., & Wiesner, J. (2021). CCA-Zoo: A collection of Regularized, Deep Learning based, Kernel, and Probabilistic CCA methods in a scikit-learn style framework. Journal of Open Source Software, 6(68), 3823. Chapman, J., Wells, L., & Lawry Aguila, A. (2024). Unconstrained Stochastic CCA: Unifying Multiview and Self-Supervised Learning. arXiv:2310.01012. Rasmussen, C. E., & Williams, C. K. I. (2006). Gaussian Processes for Machine Learning. MIT Press.
Quiñonero-Candela, J., & Rasmussen, C. E. (2005). A Unifying View of Sparse Approximate Gaussian Process Regression. Journal of Machine Learning Research, 6, 1939-1959.
Examples:
>>> import numpy as np
>>> from cca_zoo.gp import GaussianProcessCCA
>>> rng = np.random.default_rng(0)
>>> X1 = rng.standard_normal((100, 3))
>>> X2 = rng.standard_normal((100, 3))
>>> model = GaussianProcessCCA(alpha=[0.01, 0.1]).fit([X1, X2])
>>> means, stds = model.transform([X1, X2]), model.posterior_std([X1, X2])
Source code in cca_zoo/gp/_gpcca.py
fit ¶
Fit the model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
views
|
list[ArrayLike]
|
Arrays of shape (n_samples, n_features_i), one per view. |
required |
y
|
None
|
Ignored. |
None
|
Returns:
| Type | Description |
|---|---|
GaussianProcessCCA
|
self. |
Source code in cca_zoo/gp/_gpcca.py
posterior_std ¶
Posterior standard deviation of each view's latent scores.
The uncertainty of :meth:transform's scores, larger away from the
training data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
views
|
list[ArrayLike]
|
Arrays of shape (n_samples, n_features_i), one per view. |
required |
Returns:
| Type | Description |
|---|---|
list[ndarray]
|
One array of shape (n_samples, n_components) per view. |