Probabilistic Models

class cca_zoo.probabilisticmodels.ProbabilisticCCA(latent_dims: int = 1, copy_data=True, random_state: int = 0, num_samples=100, num_warmup=100)[source]

Bases: _BaseCCA

A class used to fit a Probabilistic CCA. Not quite the same due to using VI methods rather than EM

Citation

Bach, Francis R., and Michael I. Jordan. “A probabilistic interpretation of canonical correlation analysis.” (2005). Wang, Chong. “Variational Bayesian approach to canonical correlation analysis.” IEEE Transactions on Neural Networks 18.3 (2007): 905-910.

fit(views: Iterable[ndarray], y=None, **kwargs)[source]

Infer the parameters (mu: mean, psi: within view variance) and latent variables (z) of the generative CCA model

Parameters

views – list/tuple of numpy arrays or array likes with the same number of rows (samples)

transform(views: Iterable[ndarray], y=None, **kwargs)[source]

Predict the latent variables that generate the data in views using the sampled model parameters

Parameters

views – list/tuple of numpy arrays or array likes with the same number of rows (samples)

fit_transform(views: Iterable[ndarray], **kwargs)

Fits the model to the given data and returns the transformed views

Parameters
  • views (list/tuple of numpy arrays or array likes with the same number of rows (samples)) –

  • kwargs (any additional keyword arguments required by the given model) –

Returns

transformed_views

Return type

list of numpy arrays

get_factor_loadings(views: Iterable[ndarray], normalize=True, **kwargs)

Returns the factor loadings for each view

Parameters
  • views (list/tuple of numpy arrays or array likes with the same number of rows (samples)) –

  • normalize (bool, optional) – Whether to normalize the factor loadings. Default is True.

  • kwargs (any additional keyword arguments required by the given model) –

Returns

factor_loadings

Return type

list of numpy arrays

get_params(deep=True)

Get parameters for this estimator.

Parameters

deep (bool, default=True) – If True, will return the parameters for this estimator and contained subobjects that are estimators.

Returns

params – Parameter names mapped to their values.

Return type

dict

pairwise_correlations(views: Iterable[ndarray], **kwargs)

Returns the pairwise correlations between the views in each dimension

Parameters
  • views (list/tuple of numpy arrays or array likes with the same number of rows (samples)) –

  • kwargs (any additional keyword arguments required by the given model) –

Returns

pairwise_correlations

Return type

numpy array of shape (n_views, n_views, latent_dims)

score(views: Iterable[ndarray], y=None, **kwargs)

Returns the average pairwise correlation between the views

Parameters
  • views (list/tuple of numpy arrays or array likes with the same number of rows (samples)) –

  • y (None) –

  • kwargs (any additional keyword arguments required by the given model) –

Returns

score

Return type

float

set_params(**params)

Set the parameters of this estimator.

The method works on simple estimators as well as on nested objects (such as Pipeline). The latter have parameters of the form <component>__<parameter> so that it’s possible to update each component of a nested object.

Parameters

**params (dict) – Estimator parameters.

Returns

self – Estimator instance.

Return type

estimator instance