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
- Parameters
latent_dims (int, optional) – Number of latent dimensions to use, by default 1
copy_data (bool, optional) – Whether to copy the data, by default True
random_state (int, optional) – Random state, by default 0
num_samples (int, optional) – Number of samples to use in VI, by default 100
num_warmup (int, optional) – Number of warmup samples to use in VI, by default 100
References
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.
- Parameters
latent_dims (int, optional) – Number of latent dimensions to fit. Default is 1.
scale (bool, optional) – Whether to scale the data to unit variance. Default is True.
centre (bool, optional) – Whether to centre the data. Default is True.
copy_data (bool, optional) – Whether to copy the data. Default is True.
accept_sparse (bool, optional) – Whether to accept sparse data. Default is False.
random_state (int, RandomState instance or None, optional (default=None)) – Pass an int for reproducible output across multiple function calls.
- 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.
- 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
- 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