ezmsg.learn.model.cca#

Incremental Canonical Correlation Analysis (CCA).

Note

This module supports the Array API standard via array_api_compat.get_namespace(). All linear algebra uses Array API operations; scipy.linalg.sqrtm is replaced by an eigendecomposition- based inverse square root (_inv_sqrtm_spd()).

Classes

class IncrementalCCA(n_components=2, base_smoothing=0.95, min_smoothing=0.5, max_smoothing=0.99, adaptation_rate=0.1)[source]#

Bases: object

__init__(n_components=2, base_smoothing=0.95, min_smoothing=0.5, max_smoothing=0.99, adaptation_rate=0.1)[source]#

Parameters:#

n_componentsint

Number of canonical components to compute

base_smoothingfloat

Base smoothing factor (will be adapted)

min_smoothingfloat

Minimum allowed smoothing factor

max_smoothingfloat

Maximum allowed smoothing factor

adaptation_ratefloat

How quickly to adjust smoothing factor (between 0 and 1)

initialize(d1, d2, *, ref_array=None)[source]#

Initialize the necessary matrices.

Parameters:
  • d1 – Dimensionality of the first dataset.

  • d2 – Dimensionality of the second dataset.

  • ref_array – Optional reference array to derive array namespace and device from. If None, defaults to NumPy.

partial_fit(X1, X2, update_projections=True)[source]#

Update the model with new samples using adaptive smoothing. Assumes X1 and X2 are already centered and scaled.

transform(X1, X2)[source]#

Project data onto canonical components.