Stochastic Models
- class cca_zoo.models._stochastic.IncrementalPLS(latent_dims: int = 1, scale: bool = True, centre=True, copy_data=True, random_state=None, accept_sparse=None, batch_size=1, shuffle=True, sampler=None, batch_sampler=None, num_workers=0, pin_memory=False, drop_last=True, timeout=0, worker_init_fn=None, epochs=1, simple=False)[source]
Bases:
_BaseStochastic
A class used to fit Incremental PLS
- Parameters
latent_dims (int, optional) – Number of latent dimensions to use, by default 1
scale (bool, optional) – Whether to scale the data, by default True
centre (bool, optional) – Whether to centre the data, by default True
copy_data (bool, optional) – Whether to copy the data, by default True
random_state (int, optional) – Random state to use, by default None
accept_sparse (bool, optional) – Whether to accept sparse data, by default None
batch_size (int, optional) – Batch size to use, by default 1
shuffle (bool, optional) – Whether to shuffle the data, by default True
sampler (torch.utils.data.Sampler, optional) – Sampler to use, by default None
batch_sampler (torch.utils.data.Sampler, optional) – Batch sampler to use, by default None
num_workers (int, optional) – Number of workers to use, by default 0
pin_memory (bool, optional) – Whether to pin memory, by default False
drop_last (bool, optional) – Whether to drop the last batch, by default True
timeout (int, optional) – Timeout to use, by default 0
worker_init_fn (function, optional) – Worker init function to use, by default None
epochs (int, optional) – Number of epochs to use, by default 1
simple (bool, optional) – Whether to use the simple update, by default False
References
Arora, Raman, et al. “Stochastic optimization for PCA and PLS.” 2012 50th Annual Allerton Conference on Communication, Control, and Computing (Allerton). IEEE, 2012.
- 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)
Fits the model to the given data
- 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
self
- Return type
- 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
- class cca_zoo.models._stochastic.PLSStochasticPower(latent_dims: int = 1, scale: bool = True, centre=True, copy_data=True, random_state=None, accept_sparse=None, batch_size=1, shuffle=True, sampler=None, batch_sampler=None, num_workers=0, pin_memory=False, drop_last=True, timeout=0, worker_init_fn=None, epochs=1, learning_rate=0.01)[source]
Bases:
_BaseStochastic
A class used to fit Stochastic PLS
- Parameters
latent_dims (int, optional) – Number of latent dimensions to use, by default 1
scale (bool, optional) – Whether to scale the data, by default True
centre (bool, optional) – Whether to centre the data, by default True
copy_data (bool, optional) – Whether to copy the data, by default True
random_state (int, optional) – Random state to use, by default None
accept_sparse (bool, optional) – Whether to accept sparse data, by default None
batch_size (int, optional) – Batch size to use, by default 1
shuffle (bool, optional) – Whether to shuffle the data, by default True
sampler (torch.utils.data.Sampler, optional) – Sampler to use, by default None
batch_sampler (torch.utils.data.Sampler, optional) – Batch sampler to use, by default None
num_workers (int, optional) – Number of workers to use, by default 0
pin_memory (bool, optional) – Whether to pin memory, by default False
drop_last (bool, optional) – Whether to drop the last batch, by default True
timeout (int, optional) – Timeout to use, by default 0
worker_init_fn (function, optional) – Worker init function to use, by default None
epochs (int, optional) – Number of epochs to use, by default 1
learning_rate (float, optional) – Learning rate to use, by default 0.01
References
Arora, Raman, et al. “Stochastic optimization for PCA and PLS.” 2012 50th Annual Allerton Conference on Communication, Control, and Computing (Allerton). IEEE, 2012.
- 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)
Fits the model to the given data
- 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
self
- Return type
- 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
- class cca_zoo.models._stochastic.PLSGHAGEP(*args, **kwargs)[source]
Bases:
RCCAGHAGEP
A class used to fit PLS by GHA-GEP
- Parameters
latent_dims (int, optional) – Number of latent dimensions to use, by default 1
scale (bool, optional) – Whether to scale the data, by default True
centre (bool, optional) – Whether to centre the data, by default True
copy_data (bool, optional) – Whether to copy the data, by default True
random_state (int, optional) – Random state to use, by default None
accept_sparse (bool, optional) – Whether to accept sparse data, by default None
batch_size (int, optional) – Batch size to use, by default 1
shuffle (bool, optional) – Whether to shuffle the data, by default True
sampler (torch.utils.data.Sampler, optional) – Sampler to use, by default None
batch_sampler (torch.utils.data.Sampler, optional) – Batch sampler to use, by default None
num_workers (int, optional) – Number of workers to use, by default 0
pin_memory (bool, optional) – Whether to pin memory, by default False
drop_last (bool, optional) – Whether to drop the last batch, by default True
timeout (int, optional) – Timeout to use, by default 0
worker_init_fn (function, optional) – Worker init function to use, by default None
epochs (int, optional) – Number of epochs to use, by default 1
learning_rate (float, optional) – Learning rate to use, by default 0.01
References
Chapman, James, Ana Lawry Aguila, and Lennie Wells. “A Generalized EigenGame with Extensions to Multiview Representation Learning.” arXiv preprint arXiv:2211.11323 (2022).
- 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)
Fits the model to the given data
- 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
self
- Return type
- 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
- class cca_zoo.models._stochastic.CCAGHAGEP(*args, **kwargs)[source]
Bases:
RCCAGHAGEP
A class used to fit CCA by GHA-GEP
- Parameters
latent_dims (int, optional) – Number of latent dimensions to use, by default 1
scale (bool, optional) – Whether to scale the data, by default True
centre (bool, optional) – Whether to centre the data, by default True
copy_data (bool, optional) – Whether to copy the data, by default True
random_state (int, optional) – Random state to use, by default None
accept_sparse (bool, optional) – Whether to accept sparse data, by default None
batch_size (int, optional) – Batch size to use, by default 1
shuffle (bool, optional) – Whether to shuffle the data, by default True
sampler (torch.utils.data.Sampler, optional) – Sampler to use, by default None
batch_sampler (torch.utils.data.Sampler, optional) – Batch sampler to use, by default None
num_workers (int, optional) – Number of workers to use, by default 0
pin_memory (bool, optional) – Whether to pin memory, by default False
drop_last (bool, optional) – Whether to drop the last batch, by default True
timeout (int, optional) – Timeout to use, by default 0
worker_init_fn (function, optional) – Worker init function to use, by default None
epochs (int, optional) – Number of epochs to use, by default 1
learning_rate (float, optional) – Learning rate to use, by default 0.01
References
Chapman, James, Ana Lawry Aguila, and Lennie Wells. “A Generalized EigenGame with Extensions to Multiview Representation Learning.” arXiv preprint arXiv:2211.11323 (2022).
- 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)
Fits the model to the given data
- 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
self
- Return type
- 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
- class cca_zoo.models._stochastic.RCCAGHAGEP(latent_dims: int = 1, scale: bool = True, centre=True, copy_data=True, random_state=None, accept_sparse=None, batch_size=1, shuffle=True, sampler=None, batch_sampler=None, num_workers=0, pin_memory=False, drop_last=True, timeout=0, worker_init_fn=None, epochs=1, learning_rate=0.01, c=0, **kwargs)[source]
Bases:
_BaseStochastic
A class used to fit Regularized CCA by GHA-GEP
- Parameters
latent_dims (int, optional) – Number of latent dimensions to use, by default 1
scale (bool, optional) – Whether to scale the data, by default True
centre (bool, optional) – Whether to centre the data, by default True
copy_data (bool, optional) – Whether to copy the data, by default True
random_state (int, optional) – Random state to use, by default None
accept_sparse (bool, optional) – Whether to accept sparse data, by default None
batch_size (int, optional) – Batch size to use, by default 1
shuffle (bool, optional) – Whether to shuffle the data, by default True
sampler (torch.utils.data.Sampler, optional) – Sampler to use, by default None
batch_sampler (torch.utils.data.Sampler, optional) – Batch sampler to use, by default None
num_workers (int, optional) – Number of workers to use, by default 0
pin_memory (bool, optional) – Whether to pin memory, by default False
drop_last (bool, optional) – Whether to drop the last batch, by default True
timeout (int, optional) – Timeout to use, by default 0
worker_init_fn (function, optional) – Worker init function to use, by default None
epochs (int, optional) – Number of epochs to use, by default 1
learning_rate (float, optional) – Learning rate to use, by default 0.01
c (float, optional) – Regularization parameter, by default 0
References
Chapman, James, Ana Lawry Aguila, and Lennie Wells. “A Generalized EigenGame with Extensions to Multiview Representation Learning.” arXiv preprint arXiv:2211.11323 (2022).
- 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)
Fits the model to the given data
- 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
self
- Return type
- 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
- class cca_zoo.models._stochastic.PLSEigenGame(*args, **kwargs)[source]
Bases:
RCCAEigenGame
A class used to fit PLS by Delta-EigenGame
- Parameters
latent_dims (int, optional) – Number of latent dimensions to use, by default 1
scale (bool, optional) – Whether to scale the data, by default True
centre (bool, optional) – Whether to centre the data, by default True
copy_data (bool, optional) – Whether to copy the data, by default True
random_state (int, optional) – Random state to use, by default None
accept_sparse (bool, optional) – Whether to accept sparse data, by default None
batch_size (int, optional) – Batch size to use, by default 1
shuffle (bool, optional) – Whether to shuffle the data, by default True
sampler (torch.utils.data.Sampler, optional) – Sampler to use, by default None
batch_sampler (torch.utils.data.Sampler, optional) – Batch sampler to use, by default None
num_workers (int, optional) – Number of workers to use, by default 0
pin_memory (bool, optional) – Whether to pin memory, by default False
drop_last (bool, optional) – Whether to drop the last batch, by default True
timeout (int, optional) – Timeout to use, by default 0
worker_init_fn (function, optional) – Worker init function to use, by default None
epochs (int, optional) – Number of epochs to use, by default 1
learning_rate (float, optional) – Learning rate to use, by default 0.01
References
Chapman, James, Ana Lawry Aguila, and Lennie Wells. “A Generalized EigenGame with Extensions to Multiview Representation Learning.” arXiv preprint arXiv:2211.11323 (2022).
- 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)
Fits the model to the given data
- 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
self
- Return type
- 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
- class cca_zoo.models._stochastic.CCAEigenGame(*args, **kwargs)[source]
Bases:
RCCAEigenGame
A class used to fit CCA by Delta-EigenGame
- Parameters
latent_dims (int, optional) – Number of latent dimensions to use, by default 1
scale (bool, optional) – Whether to scale the data, by default True
centre (bool, optional) – Whether to centre the data, by default True
copy_data (bool, optional) – Whether to copy the data, by default True
random_state (int, optional) – Random state to use, by default None
accept_sparse (bool, optional) – Whether to accept sparse data, by default None
batch_size (int, optional) – Batch size to use, by default 1
shuffle (bool, optional) – Whether to shuffle the data, by default True
sampler (torch.utils.data.Sampler, optional) – Sampler to use, by default None
batch_sampler (torch.utils.data.Sampler, optional) – Batch sampler to use, by default None
num_workers (int, optional) – Number of workers to use, by default 0
pin_memory (bool, optional) – Whether to pin memory, by default False
drop_last (bool, optional) – Whether to drop the last batch, by default True
timeout (int, optional) – Timeout to use, by default 0
worker_init_fn (function, optional) – Worker init function to use, by default None
epochs (int, optional) – Number of epochs to use, by default 1
learning_rate (float, optional) – Learning rate to use, by default 0.01
References
Chapman, James, Ana Lawry Aguila, and Lennie Wells. “A Generalized EigenGame with Extensions to Multiview Representation Learning.” arXiv preprint arXiv:2211.11323 (2022).
- 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)
Fits the model to the given data
- 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
self
- Return type
- 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
- class cca_zoo.models._stochastic.RCCAEigenGame(latent_dims: int = 1, scale: bool = True, centre=True, copy_data=True, random_state=None, accept_sparse=None, batch_size=1, shuffle=True, sampler=None, batch_sampler=None, num_workers=0, pin_memory=False, drop_last=True, timeout=0, worker_init_fn=None, epochs=1, learning_rate=0.01, c=0, **kwargs)[source]
Bases:
_BaseStochastic
A class used to fit Regularized CCA by Delta-EigenGame
- Parameters
latent_dims (int, optional) – Number of latent dimensions to use, by default 1
scale (bool, optional) – Whether to scale the data, by default True
centre (bool, optional) – Whether to centre the data, by default True
copy_data (bool, optional) – Whether to copy the data, by default True
random_state (int, optional) – Random state to use, by default None
accept_sparse (bool, optional) – Whether to accept sparse data, by default None
batch_size (int, optional) – Batch size to use, by default 1
shuffle (bool, optional) – Whether to shuffle the data, by default True
sampler (torch.utils.data.Sampler, optional) – Sampler to use, by default None
batch_sampler (torch.utils.data.Sampler, optional) – Batch sampler to use, by default None
num_workers (int, optional) – Number of workers to use, by default 0
pin_memory (bool, optional) – Whether to pin memory, by default False
drop_last (bool, optional) – Whether to drop the last batch, by default True
timeout (int, optional) – Timeout to use, by default 0
worker_init_fn (function, optional) – Worker init function to use, by default None
epochs (int, optional) – Number of epochs to use, by default 1
learning_rate (float, optional) – Learning rate to use, by default 0.01
c (float, optional) – Regularization parameter, by default 0
References
Chapman, James, Ana Lawry Aguila, and Lennie Wells. “A Generalized EigenGame with Extensions to Multiview Representation Learning.” arXiv preprint arXiv:2211.11323 (2022).
- 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)
Fits the model to the given data
- 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
self
- Return type
- 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