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, val_interval=10)[source]

Bases: _BaseStochastic

A class used to fit Incremental PLS

References

Arora, Raman, et al. “Stochastic optimization for PCA and PLS.” 2012 50th Annual Allerton Conference on Communication, Control, and Computing (Allerton). IEEE, 2012.

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

object

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

transform(views: Iterable[ndarray], **kwargs)
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

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

References

Arora, Raman, et al. “Stochastic optimization for PCA and PLS.” 2012 50th Annual Allerton Conference on Communication, Control, and Computing (Allerton). IEEE, 2012.

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

object

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

transform(views: Iterable[ndarray], **kwargs)
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

class cca_zoo.models._stochastic.PLSGHAGEP(*args, **kwargs)[source]

Bases: RCCAGHAGEP

References

Chapman, James, Ana Lawry Aguila, and Lennie Wells. “A Generalized EigenGame with Extensions to Multiview Representation Learning.” arXiv preprint arXiv:2211.11323 (2022).

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

object

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

transform(views: Iterable[ndarray], **kwargs)
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

class cca_zoo.models._stochastic.CCAGHAGEP(*args, **kwargs)[source]

Bases: RCCAGHAGEP

References

Chapman, James, Ana Lawry Aguila, and Lennie Wells. “A Generalized EigenGame with Extensions to Multiview Representation Learning.” arXiv preprint arXiv:2211.11323 (2022).

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

object

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

transform(views: Iterable[ndarray], **kwargs)
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

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)[source]

Bases: _BaseStochastic

References

Chapman, James, Ana Lawry Aguila, and Lennie Wells. “A Generalized EigenGame with Extensions to Multiview Representation Learning.” arXiv preprint arXiv:2211.11323 (2022).

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

object

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

transform(views: Iterable[ndarray], **kwargs)
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

class cca_zoo.models._stochastic.PLSEigenGame(*args, **kwargs)[source]

Bases: RCCAEigenGame

References

Chapman, James, Ana Lawry Aguila, and Lennie Wells. “A Generalized EigenGame with Extensions to Multiview Representation Learning.” arXiv preprint arXiv:2211.11323 (2022).

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

object

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

transform(views: Iterable[ndarray], **kwargs)
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

class cca_zoo.models._stochastic.CCAEigenGame(*args, **kwargs)[source]

Bases: RCCAEigenGame

References

Chapman, James, Ana Lawry Aguila, and Lennie Wells. “A Generalized EigenGame with Extensions to Multiview Representation Learning.” arXiv preprint arXiv:2211.11323 (2022).

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

object

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

transform(views: Iterable[ndarray], **kwargs)
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

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)[source]

Bases: _BaseStochastic

References

Chapman, James, Ana Lawry Aguila, and Lennie Wells. “A Generalized EigenGame with Extensions to Multiview Representation Learning.” arXiv preprint arXiv:2211.11323 (2022).

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

object

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

transform(views: Iterable[ndarray], **kwargs)
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