cca_zoo.linear
- class cca_zoo.linear.CCA(latent_dimensions: int = 1, copy_data=True, random_state=None)[source]
A class used to fit a simple CCA model. This model finds the linear projections of two views that maximize their correlation.
The objective function of CCA is:
\[ \begin{align}\begin{aligned}\begin{split}w_{opt}=\underset{w}{\mathrm{argmax}}\{ w_1^TX_1^TX_2w_2 \}\\\end{split}\\\text{subject to:}\\w_1^TX_1^TX_1w_1=n\\w_2^TX_2^TX_2w_2=n\end{aligned}\end{align} \]- Parameters:
References
Hotelling, Harold. “Relations between two sets of variates.” Breakthroughs in statistics. Springer, New York, NY, 1992. 162-190.
Example
>>> from cca_zoo.linear import CCA >>> import numpy as np >>> rng=np.random.RandomState(0) >>> X1 = rng.random((10,5)) >>> X2 = rng.random((10,5)) >>> model = CCA() >>> model.fit((X1,X2)).score((X1,X2)) array([1.])
- 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
- 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_metadata_routing()
Get metadata routing of this object.
Please check User Guide on how the routing mechanism works.
- Returns:
routing – A
MetadataRequest
encapsulating routing information.- Return type:
MetadataRequest
- 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_dimensions)
- 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_fit_request(*, views: bool | None | str = '$UNCHANGED$') CCA
Request metadata passed to the
fit
method.Note that this method is only relevant if
enable_metadata_routing=True
(seesklearn.set_config()
). Please see User Guide on how the routing mechanism works.The options for each parameter are:
True
: metadata is requested, and passed tofit
if provided. The request is ignored if metadata is not provided.False
: metadata is not requested and the meta-estimator will not pass it tofit
.None
: metadata is not requested, and the meta-estimator will raise an error if the user provides it.str
: metadata should be passed to the meta-estimator with this given alias instead of the original name.
The default (
sklearn.utils.metadata_routing.UNCHANGED
) retains the existing request. This allows you to change the request for some parameters and not others.New in version 1.3.
Note
This method is only relevant if this estimator is used as a sub-estimator of a meta-estimator, e.g. used inside a
pipeline.Pipeline
. Otherwise it has no effect.
- 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
- set_score_request(*, views: bool | None | str = '$UNCHANGED$') CCA
Request metadata passed to the
score
method.Note that this method is only relevant if
enable_metadata_routing=True
(seesklearn.set_config()
). Please see User Guide on how the routing mechanism works.The options for each parameter are:
True
: metadata is requested, and passed toscore
if provided. The request is ignored if metadata is not provided.False
: metadata is not requested and the meta-estimator will not pass it toscore
.None
: metadata is not requested, and the meta-estimator will raise an error if the user provides it.str
: metadata should be passed to the meta-estimator with this given alias instead of the original name.
The default (
sklearn.utils.metadata_routing.UNCHANGED
) retains the existing request. This allows you to change the request for some parameters and not others.New in version 1.3.
Note
This method is only relevant if this estimator is used as a sub-estimator of a meta-estimator, e.g. used inside a
pipeline.Pipeline
. Otherwise it has no effect.
- set_transform_request(*, views: bool | None | str = '$UNCHANGED$') CCA
Request metadata passed to the
transform
method.Note that this method is only relevant if
enable_metadata_routing=True
(seesklearn.set_config()
). Please see User Guide on how the routing mechanism works.The options for each parameter are:
True
: metadata is requested, and passed totransform
if provided. The request is ignored if metadata is not provided.False
: metadata is not requested and the meta-estimator will not pass it totransform
.None
: metadata is not requested, and the meta-estimator will raise an error if the user provides it.str
: metadata should be passed to the meta-estimator with this given alias instead of the original name.
The default (
sklearn.utils.metadata_routing.UNCHANGED
) retains the existing request. This allows you to change the request for some parameters and not others.New in version 1.3.
Note
This method is only relevant if this estimator is used as a sub-estimator of a meta-estimator, e.g. used inside a
pipeline.Pipeline
. Otherwise it has no effect.
- class cca_zoo.linear.CCAEY(latent_dimensions: int = 1, copy_data=True, random_state=None, tol=1e-09, accept_sparse=None, batch_size=None, epochs=100, learning_rate=0.1, initialization: str | callable = 'random', dataloader_kwargs=None, optimizer_kwargs=None, convergence_checking=None, patience=10, track=None, verbose=False)[source]
A class used to fit Regularized CCA by Delta-EigenGame
- Parameters:
latent_dimensions (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 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
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 GeneralizedDeflation EigenGame with Extensions to Multiview Representation Learning.” arXiv preprint arXiv:2211.11323 (2022).
- 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
- 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_metadata_routing()
Get metadata routing of this object.
Please check User Guide on how the routing mechanism works.
- Returns:
routing – A
MetadataRequest
encapsulating routing information.- Return type:
MetadataRequest
- 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_dimensions)
- 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_fit_request(*, views: bool | None | str = '$UNCHANGED$') CCAEY
Request metadata passed to the
fit
method.Note that this method is only relevant if
enable_metadata_routing=True
(seesklearn.set_config()
). Please see User Guide on how the routing mechanism works.The options for each parameter are:
True
: metadata is requested, and passed tofit
if provided. The request is ignored if metadata is not provided.False
: metadata is not requested and the meta-estimator will not pass it tofit
.None
: metadata is not requested, and the meta-estimator will raise an error if the user provides it.str
: metadata should be passed to the meta-estimator with this given alias instead of the original name.
The default (
sklearn.utils.metadata_routing.UNCHANGED
) retains the existing request. This allows you to change the request for some parameters and not others.New in version 1.3.
Note
This method is only relevant if this estimator is used as a sub-estimator of a meta-estimator, e.g. used inside a
pipeline.Pipeline
. Otherwise it has no effect.
- 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
- set_score_request(*, views: bool | None | str = '$UNCHANGED$') CCAEY
Request metadata passed to the
score
method.Note that this method is only relevant if
enable_metadata_routing=True
(seesklearn.set_config()
). Please see User Guide on how the routing mechanism works.The options for each parameter are:
True
: metadata is requested, and passed toscore
if provided. The request is ignored if metadata is not provided.False
: metadata is not requested and the meta-estimator will not pass it toscore
.None
: metadata is not requested, and the meta-estimator will raise an error if the user provides it.str
: metadata should be passed to the meta-estimator with this given alias instead of the original name.
The default (
sklearn.utils.metadata_routing.UNCHANGED
) retains the existing request. This allows you to change the request for some parameters and not others.New in version 1.3.
Note
This method is only relevant if this estimator is used as a sub-estimator of a meta-estimator, e.g. used inside a
pipeline.Pipeline
. Otherwise it has no effect.
- set_transform_request(*, views: bool | None | str = '$UNCHANGED$') CCAEY
Request metadata passed to the
transform
method.Note that this method is only relevant if
enable_metadata_routing=True
(seesklearn.set_config()
). Please see User Guide on how the routing mechanism works.The options for each parameter are:
True
: metadata is requested, and passed totransform
if provided. The request is ignored if metadata is not provided.False
: metadata is not requested and the meta-estimator will not pass it totransform
.None
: metadata is not requested, and the meta-estimator will raise an error if the user provides it.str
: metadata should be passed to the meta-estimator with this given alias instead of the original name.
The default (
sklearn.utils.metadata_routing.UNCHANGED
) retains the existing request. This allows you to change the request for some parameters and not others.New in version 1.3.
Note
This method is only relevant if this estimator is used as a sub-estimator of a meta-estimator, e.g. used inside a
pipeline.Pipeline
. Otherwise it has no effect.
- class cca_zoo.linear.CCAGH(latent_dimensions: int = 1, copy_data=True, random_state=None, tol=1e-09, accept_sparse=None, batch_size=None, epochs=100, learning_rate=0.1, initialization: str | callable = 'random', dataloader_kwargs=None, optimizer_kwargs=None, convergence_checking=None, patience=10, track=None, verbose=False)[source]
- 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
- 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_metadata_routing()
Get metadata routing of this object.
Please check User Guide on how the routing mechanism works.
- Returns:
routing – A
MetadataRequest
encapsulating routing information.- Return type:
MetadataRequest
- 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_dimensions)
- 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_fit_request(*, views: bool | None | str = '$UNCHANGED$') CCAGH
Request metadata passed to the
fit
method.Note that this method is only relevant if
enable_metadata_routing=True
(seesklearn.set_config()
). Please see User Guide on how the routing mechanism works.The options for each parameter are:
True
: metadata is requested, and passed tofit
if provided. The request is ignored if metadata is not provided.False
: metadata is not requested and the meta-estimator will not pass it tofit
.None
: metadata is not requested, and the meta-estimator will raise an error if the user provides it.str
: metadata should be passed to the meta-estimator with this given alias instead of the original name.
The default (
sklearn.utils.metadata_routing.UNCHANGED
) retains the existing request. This allows you to change the request for some parameters and not others.New in version 1.3.
Note
This method is only relevant if this estimator is used as a sub-estimator of a meta-estimator, e.g. used inside a
pipeline.Pipeline
. Otherwise it has no effect.
- 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
- set_score_request(*, views: bool | None | str = '$UNCHANGED$') CCAGH
Request metadata passed to the
score
method.Note that this method is only relevant if
enable_metadata_routing=True
(seesklearn.set_config()
). Please see User Guide on how the routing mechanism works.The options for each parameter are:
True
: metadata is requested, and passed toscore
if provided. The request is ignored if metadata is not provided.False
: metadata is not requested and the meta-estimator will not pass it toscore
.None
: metadata is not requested, and the meta-estimator will raise an error if the user provides it.str
: metadata should be passed to the meta-estimator with this given alias instead of the original name.
The default (
sklearn.utils.metadata_routing.UNCHANGED
) retains the existing request. This allows you to change the request for some parameters and not others.New in version 1.3.
Note
This method is only relevant if this estimator is used as a sub-estimator of a meta-estimator, e.g. used inside a
pipeline.Pipeline
. Otherwise it has no effect.
- set_transform_request(*, views: bool | None | str = '$UNCHANGED$') CCAGH
Request metadata passed to the
transform
method.Note that this method is only relevant if
enable_metadata_routing=True
(seesklearn.set_config()
). Please see User Guide on how the routing mechanism works.The options for each parameter are:
True
: metadata is requested, and passed totransform
if provided. The request is ignored if metadata is not provided.False
: metadata is not requested and the meta-estimator will not pass it totransform
.None
: metadata is not requested, and the meta-estimator will raise an error if the user provides it.str
: metadata should be passed to the meta-estimator with this given alias instead of the original name.
The default (
sklearn.utils.metadata_routing.UNCHANGED
) retains the existing request. This allows you to change the request for some parameters and not others.New in version 1.3.
Note
This method is only relevant if this estimator is used as a sub-estimator of a meta-estimator, e.g. used inside a
pipeline.Pipeline
. Otherwise it has no effect.
- class cca_zoo.linear.CCASVD(latent_dimensions: int = 1, copy_data=True, random_state=None, tol=1e-09, accept_sparse=None, batch_size=None, epochs=100, learning_rate=0.1, initialization: str | callable = 'random', dataloader_kwargs=None, optimizer_kwargs=None, convergence_checking=None, patience=10, track=None, verbose=False)[source]
- 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
- 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_metadata_routing()
Get metadata routing of this object.
Please check User Guide on how the routing mechanism works.
- Returns:
routing – A
MetadataRequest
encapsulating routing information.- Return type:
MetadataRequest
- 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_dimensions)
- 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_fit_request(*, views: bool | None | str = '$UNCHANGED$') CCASVD
Request metadata passed to the
fit
method.Note that this method is only relevant if
enable_metadata_routing=True
(seesklearn.set_config()
). Please see User Guide on how the routing mechanism works.The options for each parameter are:
True
: metadata is requested, and passed tofit
if provided. The request is ignored if metadata is not provided.False
: metadata is not requested and the meta-estimator will not pass it tofit
.None
: metadata is not requested, and the meta-estimator will raise an error if the user provides it.str
: metadata should be passed to the meta-estimator with this given alias instead of the original name.
The default (
sklearn.utils.metadata_routing.UNCHANGED
) retains the existing request. This allows you to change the request for some parameters and not others.New in version 1.3.
Note
This method is only relevant if this estimator is used as a sub-estimator of a meta-estimator, e.g. used inside a
pipeline.Pipeline
. Otherwise it has no effect.
- 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
- set_score_request(*, views: bool | None | str = '$UNCHANGED$') CCASVD
Request metadata passed to the
score
method.Note that this method is only relevant if
enable_metadata_routing=True
(seesklearn.set_config()
). Please see User Guide on how the routing mechanism works.The options for each parameter are:
True
: metadata is requested, and passed toscore
if provided. The request is ignored if metadata is not provided.False
: metadata is not requested and the meta-estimator will not pass it toscore
.None
: metadata is not requested, and the meta-estimator will raise an error if the user provides it.str
: metadata should be passed to the meta-estimator with this given alias instead of the original name.
The default (
sklearn.utils.metadata_routing.UNCHANGED
) retains the existing request. This allows you to change the request for some parameters and not others.New in version 1.3.
Note
This method is only relevant if this estimator is used as a sub-estimator of a meta-estimator, e.g. used inside a
pipeline.Pipeline
. Otherwise it has no effect.
- set_transform_request(*, views: bool | None | str = '$UNCHANGED$') CCASVD
Request metadata passed to the
transform
method.Note that this method is only relevant if
enable_metadata_routing=True
(seesklearn.set_config()
). Please see User Guide on how the routing mechanism works.The options for each parameter are:
True
: metadata is requested, and passed totransform
if provided. The request is ignored if metadata is not provided.False
: metadata is not requested and the meta-estimator will not pass it totransform
.None
: metadata is not requested, and the meta-estimator will raise an error if the user provides it.str
: metadata should be passed to the meta-estimator with this given alias instead of the original name.
The default (
sklearn.utils.metadata_routing.UNCHANGED
) retains the existing request. This allows you to change the request for some parameters and not others.New in version 1.3.
Note
This method is only relevant if this estimator is used as a sub-estimator of a meta-estimator, e.g. used inside a
pipeline.Pipeline
. Otherwise it has no effect.
- class cca_zoo.linear.ElasticCCA(latent_dimensions: int = 1, copy_data=True, random_state=None, tol=0.001, accept_sparse=None, epochs=100, initialization: str | callable = 'uniform', early_stopping=False, verbose=None, alpha=None, l1_ratio=None, positive=None, stochastic=False)[source]
- 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
- 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_metadata_routing()
Get metadata routing of this object.
Please check User Guide on how the routing mechanism works.
- Returns:
routing – A
MetadataRequest
encapsulating routing information.- Return type:
MetadataRequest
- 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_dimensions)
- 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_fit_request(*, views: bool | None | str = '$UNCHANGED$') ElasticCCA
Request metadata passed to the
fit
method.Note that this method is only relevant if
enable_metadata_routing=True
(seesklearn.set_config()
). Please see User Guide on how the routing mechanism works.The options for each parameter are:
True
: metadata is requested, and passed tofit
if provided. The request is ignored if metadata is not provided.False
: metadata is not requested and the meta-estimator will not pass it tofit
.None
: metadata is not requested, and the meta-estimator will raise an error if the user provides it.str
: metadata should be passed to the meta-estimator with this given alias instead of the original name.
The default (
sklearn.utils.metadata_routing.UNCHANGED
) retains the existing request. This allows you to change the request for some parameters and not others.New in version 1.3.
Note
This method is only relevant if this estimator is used as a sub-estimator of a meta-estimator, e.g. used inside a
pipeline.Pipeline
. Otherwise it has no effect.
- 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
- set_score_request(*, views: bool | None | str = '$UNCHANGED$') ElasticCCA
Request metadata passed to the
score
method.Note that this method is only relevant if
enable_metadata_routing=True
(seesklearn.set_config()
). Please see User Guide on how the routing mechanism works.The options for each parameter are:
True
: metadata is requested, and passed toscore
if provided. The request is ignored if metadata is not provided.False
: metadata is not requested and the meta-estimator will not pass it toscore
.None
: metadata is not requested, and the meta-estimator will raise an error if the user provides it.str
: metadata should be passed to the meta-estimator with this given alias instead of the original name.
The default (
sklearn.utils.metadata_routing.UNCHANGED
) retains the existing request. This allows you to change the request for some parameters and not others.New in version 1.3.
Note
This method is only relevant if this estimator is used as a sub-estimator of a meta-estimator, e.g. used inside a
pipeline.Pipeline
. Otherwise it has no effect.
- set_transform_request(*, views: bool | None | str = '$UNCHANGED$') ElasticCCA
Request metadata passed to the
transform
method.Note that this method is only relevant if
enable_metadata_routing=True
(seesklearn.set_config()
). Please see User Guide on how the routing mechanism works.The options for each parameter are:
True
: metadata is requested, and passed totransform
if provided. The request is ignored if metadata is not provided.False
: metadata is not requested and the meta-estimator will not pass it totransform
.None
: metadata is not requested, and the meta-estimator will raise an error if the user provides it.str
: metadata should be passed to the meta-estimator with this given alias instead of the original name.
The default (
sklearn.utils.metadata_routing.UNCHANGED
) retains the existing request. This allows you to change the request for some parameters and not others.New in version 1.3.
Note
This method is only relevant if this estimator is used as a sub-estimator of a meta-estimator, e.g. used inside a
pipeline.Pipeline
. Otherwise it has no effect.
- class cca_zoo.linear.GCCA(latent_dimensions: int = 1, copy_data=True, random_state=None, c: Iterable[float] | float = None, view_weights: Iterable[float] = None, eps: float = 1e-06)[source]
A class used to fit GCCA model. This model extends CCA to more than two views by optimizing the sum of correlations with a shared auxiliary vector.
The objective function of GCCA is:
\[ \begin{align}\begin{aligned}\begin{split}w_{opt}=\underset{w}{\mathrm{argmax}}\{ \sum_iw_i^TX_i^TT \}\\\end{split}\\\text{subject to:}\\T^TT=1\end{aligned}\end{align} \]where \(T\) is the auxiliary vector.
References
Tenenhaus, Arthur, and Michel Tenenhaus. “Regularized generalized canonical correlation analysis.” Psychometrika 76.2 (2011): 257.
Examples
>>> from cca_zoo.linear import GCCA >>> import numpy as np >>> rng=np.random.RandomState(0) >>> X1 = rng.random((10,5)) >>> X2 = rng.random((10,5)) >>> X3 = rng.random((10,5)) >>> model = GCCA() >>> model.fit((X1,X2,X3)).score((X1,X2,X3)) array([0.97229856])
- 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
- fit(views: Iterable[ndarray], y=None, K=None, **kwargs)[source]
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_metadata_routing()
Get metadata routing of this object.
Please check User Guide on how the routing mechanism works.
- Returns:
routing – A
MetadataRequest
encapsulating routing information.- Return type:
MetadataRequest
- 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_dimensions)
- 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_fit_request(*, K: bool | None | str = '$UNCHANGED$', views: bool | None | str = '$UNCHANGED$') GCCA
Request metadata passed to the
fit
method.Note that this method is only relevant if
enable_metadata_routing=True
(seesklearn.set_config()
). Please see User Guide on how the routing mechanism works.The options for each parameter are:
True
: metadata is requested, and passed tofit
if provided. The request is ignored if metadata is not provided.False
: metadata is not requested and the meta-estimator will not pass it tofit
.None
: metadata is not requested, and the meta-estimator will raise an error if the user provides it.str
: metadata should be passed to the meta-estimator with this given alias instead of the original name.
The default (
sklearn.utils.metadata_routing.UNCHANGED
) retains the existing request. This allows you to change the request for some parameters and not others.New in version 1.3.
Note
This method is only relevant if this estimator is used as a sub-estimator of a meta-estimator, e.g. used inside a
pipeline.Pipeline
. Otherwise it has no effect.- Parameters:
- Returns:
self – The updated object.
- 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
- set_score_request(*, views: bool | None | str = '$UNCHANGED$') GCCA
Request metadata passed to the
score
method.Note that this method is only relevant if
enable_metadata_routing=True
(seesklearn.set_config()
). Please see User Guide on how the routing mechanism works.The options for each parameter are:
True
: metadata is requested, and passed toscore
if provided. The request is ignored if metadata is not provided.False
: metadata is not requested and the meta-estimator will not pass it toscore
.None
: metadata is not requested, and the meta-estimator will raise an error if the user provides it.str
: metadata should be passed to the meta-estimator with this given alias instead of the original name.
The default (
sklearn.utils.metadata_routing.UNCHANGED
) retains the existing request. This allows you to change the request for some parameters and not others.New in version 1.3.
Note
This method is only relevant if this estimator is used as a sub-estimator of a meta-estimator, e.g. used inside a
pipeline.Pipeline
. Otherwise it has no effect.
- set_transform_request(*, views: bool | None | str = '$UNCHANGED$') GCCA
Request metadata passed to the
transform
method.Note that this method is only relevant if
enable_metadata_routing=True
(seesklearn.set_config()
). Please see User Guide on how the routing mechanism works.The options for each parameter are:
True
: metadata is requested, and passed totransform
if provided. The request is ignored if metadata is not provided.False
: metadata is not requested and the meta-estimator will not pass it totransform
.None
: metadata is not requested, and the meta-estimator will raise an error if the user provides it.str
: metadata should be passed to the meta-estimator with this given alias instead of the original name.
The default (
sklearn.utils.metadata_routing.UNCHANGED
) retains the existing request. This allows you to change the request for some parameters and not others.New in version 1.3.
Note
This method is only relevant if this estimator is used as a sub-estimator of a meta-estimator, e.g. used inside a
pipeline.Pipeline
. Otherwise it has no effect.
- class cca_zoo.linear.GRCCA(latent_dimensions: int = 1, copy_data=True, random_state=None, eps=0.001, c: float = 0, mu: float = 0)[source]
Grouped Regularized Canonical Correlation Analysis
- Parameters:
latent_dimensions (int, default=1) – Number of latent dimensions to use
copy_data (bool, default=True) – Whether to copy the data
random_state (int, default=None) – Random state for initialisation
eps (float, default=1e-3) – Tolerance for convergence
c (float, default=0) – Regularization parameter for the group means
mu (float, default=0) – Regularization parameter for the group sizes
References
Tuzhilina, Elena, Leonardo Tozzi, and Trevor Hastie. “Canonical correlation analysis in high dimensions with structured regularization.” Statistical Modelling (2021): 1471082X211041033.
- 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
- fit(views: Iterable[ndarray], y=None, feature_groups=None, **kwargs)[source]
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_metadata_routing()
Get metadata routing of this object.
Please check User Guide on how the routing mechanism works.
- Returns:
routing – A
MetadataRequest
encapsulating routing information.- Return type:
MetadataRequest
- 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_dimensions)
- 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_fit_request(*, feature_groups: bool | None | str = '$UNCHANGED$', views: bool | None | str = '$UNCHANGED$') GRCCA
Request metadata passed to the
fit
method.Note that this method is only relevant if
enable_metadata_routing=True
(seesklearn.set_config()
). Please see User Guide on how the routing mechanism works.The options for each parameter are:
True
: metadata is requested, and passed tofit
if provided. The request is ignored if metadata is not provided.False
: metadata is not requested and the meta-estimator will not pass it tofit
.None
: metadata is not requested, and the meta-estimator will raise an error if the user provides it.str
: metadata should be passed to the meta-estimator with this given alias instead of the original name.
The default (
sklearn.utils.metadata_routing.UNCHANGED
) retains the existing request. This allows you to change the request for some parameters and not others.New in version 1.3.
Note
This method is only relevant if this estimator is used as a sub-estimator of a meta-estimator, e.g. used inside a
pipeline.Pipeline
. Otherwise it has no effect.- Parameters:
- Returns:
self – The updated object.
- 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
- set_score_request(*, views: bool | None | str = '$UNCHANGED$') GRCCA
Request metadata passed to the
score
method.Note that this method is only relevant if
enable_metadata_routing=True
(seesklearn.set_config()
). Please see User Guide on how the routing mechanism works.The options for each parameter are:
True
: metadata is requested, and passed toscore
if provided. The request is ignored if metadata is not provided.False
: metadata is not requested and the meta-estimator will not pass it toscore
.None
: metadata is not requested, and the meta-estimator will raise an error if the user provides it.str
: metadata should be passed to the meta-estimator with this given alias instead of the original name.
The default (
sklearn.utils.metadata_routing.UNCHANGED
) retains the existing request. This allows you to change the request for some parameters and not others.New in version 1.3.
Note
This method is only relevant if this estimator is used as a sub-estimator of a meta-estimator, e.g. used inside a
pipeline.Pipeline
. Otherwise it has no effect.
- set_transform_request(*, views: bool | None | str = '$UNCHANGED$') GRCCA
Request metadata passed to the
transform
method.Note that this method is only relevant if
enable_metadata_routing=True
(seesklearn.set_config()
). Please see User Guide on how the routing mechanism works.The options for each parameter are:
True
: metadata is requested, and passed totransform
if provided. The request is ignored if metadata is not provided.False
: metadata is not requested and the meta-estimator will not pass it totransform
.None
: metadata is not requested, and the meta-estimator will raise an error if the user provides it.str
: metadata should be passed to the meta-estimator with this given alias instead of the original name.
The default (
sklearn.utils.metadata_routing.UNCHANGED
) retains the existing request. This allows you to change the request for some parameters and not others.New in version 1.3.
Note
This method is only relevant if this estimator is used as a sub-estimator of a meta-estimator, e.g. used inside a
pipeline.Pipeline
. Otherwise it has no effect.
- class cca_zoo.linear.MCCA(latent_dimensions: int = 1, copy_data=True, random_state=None, c: Iterable[float] | float = None, accept_sparse=None, eps: float = 1e-06, pca: bool = True)[source]
A class used to fit Regularised CCA (canonical ridge) model. This model adds a regularization term to the CCA objective function to avoid overfitting and improve stability. It uses PCA to perform the optimization efficiently for high dimensional data.
The objective function of regularised CCA is:
\[ \begin{align}\begin{aligned}\begin{split}w_{opt}=\underset{w}{\mathrm{argmax}}\{ w_1^TX_1^TX_2w_2 \}\\\end{split}\\\text{subject to:}\\(1-c_1)w_1^TX_1^TX_1w_1+c_1w_1^Tw_1=n\\(1-c_2)w_2^TX_2^TX_2w_2+c_2w_2^Tw_2=n\end{aligned}\end{align} \]where \(c_i\) are the regularization parameters for each view.
- Parameters:
latent_dimensions (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 None
c (Union[Iterable[float], float], optional) – Regularisation parameter, by default None
accept_sparse (Union[bool, str], optional) – Whether to accept sparse data, by default None
References
Vinod, Hrishikesh _D. “Canonical ridge and econometrics of joint production.” Journal of econometrics 4.2 (1976): 147-166.
- 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
- fit(views: Iterable[ndarray], y=None, **kwargs)[source]
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_metadata_routing()
Get metadata routing of this object.
Please check User Guide on how the routing mechanism works.
- Returns:
routing – A
MetadataRequest
encapsulating routing information.- Return type:
MetadataRequest
- 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_dimensions)
- 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_fit_request(*, views: bool | None | str = '$UNCHANGED$') MCCA
Request metadata passed to the
fit
method.Note that this method is only relevant if
enable_metadata_routing=True
(seesklearn.set_config()
). Please see User Guide on how the routing mechanism works.The options for each parameter are:
True
: metadata is requested, and passed tofit
if provided. The request is ignored if metadata is not provided.False
: metadata is not requested and the meta-estimator will not pass it tofit
.None
: metadata is not requested, and the meta-estimator will raise an error if the user provides it.str
: metadata should be passed to the meta-estimator with this given alias instead of the original name.
The default (
sklearn.utils.metadata_routing.UNCHANGED
) retains the existing request. This allows you to change the request for some parameters and not others.New in version 1.3.
Note
This method is only relevant if this estimator is used as a sub-estimator of a meta-estimator, e.g. used inside a
pipeline.Pipeline
. Otherwise it has no effect.
- 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
- set_score_request(*, views: bool | None | str = '$UNCHANGED$') MCCA
Request metadata passed to the
score
method.Note that this method is only relevant if
enable_metadata_routing=True
(seesklearn.set_config()
). Please see User Guide on how the routing mechanism works.The options for each parameter are:
True
: metadata is requested, and passed toscore
if provided. The request is ignored if metadata is not provided.False
: metadata is not requested and the meta-estimator will not pass it toscore
.None
: metadata is not requested, and the meta-estimator will raise an error if the user provides it.str
: metadata should be passed to the meta-estimator with this given alias instead of the original name.
The default (
sklearn.utils.metadata_routing.UNCHANGED
) retains the existing request. This allows you to change the request for some parameters and not others.New in version 1.3.
Note
This method is only relevant if this estimator is used as a sub-estimator of a meta-estimator, e.g. used inside a
pipeline.Pipeline
. Otherwise it has no effect.
- set_transform_request(*, views: bool | None | str = '$UNCHANGED$') MCCA
Request metadata passed to the
transform
method.Note that this method is only relevant if
enable_metadata_routing=True
(seesklearn.set_config()
). Please see User Guide on how the routing mechanism works.The options for each parameter are:
True
: metadata is requested, and passed totransform
if provided. The request is ignored if metadata is not provided.False
: metadata is not requested and the meta-estimator will not pass it totransform
.None
: metadata is not requested, and the meta-estimator will raise an error if the user provides it.str
: metadata should be passed to the meta-estimator with this given alias instead of the original name.
The default (
sklearn.utils.metadata_routing.UNCHANGED
) retains the existing request. This allows you to change the request for some parameters and not others.New in version 1.3.
Note
This method is only relevant if this estimator is used as a sub-estimator of a meta-estimator, e.g. used inside a
pipeline.Pipeline
. Otherwise it has no effect.
- class cca_zoo.linear.MPLS(latent_dimensions: int = 1, copy_data=True, random_state=None)[source]
A class used to fit a mutiview PLS model. This model finds the linear projections of two views that maximize their covariance.
Implements PLS by inheriting regularised CCA with maximal regularisation. This is equivalent to solving the following optimization problem:
- Parameters:
- explained_covariance_(views: Iterable[ndarray], **kwargs) ndarray
Returns the total covariance for each view
- 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:
covariance
- Return type:
numpy array of shape (n_views, latent_dimensions)
- explained_covariance_cumulative_(views: Iterable[ndarray], **kwargs)
Returns the cumulative explained covariance for each view
- 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:
explained_covariance_cumulative_
- Return type:
numpy array of shape (n_views, latent_dimensions)
- explained_covariance_ratio_(views: Iterable[ndarray], **kwargs) ndarray
Returns the explained covariance ratio for each view
- 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:
explained_covariance_ratio_
- Return type:
numpy array of shape (n_views, latent_dimensions)
- explained_variance_(views: Iterable[ndarray], **kwargs) ndarray
Returns the total variance for each view
- 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:
variance
- Return type:
numpy array of shape (n_views, latent_dimensions)
- explained_variance_cumulative_(views: Iterable[ndarray], **kwargs) ndarray
Returns the cumulative explained variance for each view
- 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:
explained_variance_cumulative_
- Return type:
numpy array of shape (n_views, latent_dimensions)
- explained_variance_ratio_(views: Iterable[ndarray], **kwargs) ndarray
Returns the explained variance ratio for each view
- 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:
explained_variance_ratio
- Return type:
numpy array of shape (n_views, latent_dimensions)
- 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
- 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_metadata_routing()
Get metadata routing of this object.
Please check User Guide on how the routing mechanism works.
- Returns:
routing – A
MetadataRequest
encapsulating routing information.- Return type:
MetadataRequest
- 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_dimensions)
- 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_fit_request(*, views: bool | None | str = '$UNCHANGED$') MPLS
Request metadata passed to the
fit
method.Note that this method is only relevant if
enable_metadata_routing=True
(seesklearn.set_config()
). Please see User Guide on how the routing mechanism works.The options for each parameter are:
True
: metadata is requested, and passed tofit
if provided. The request is ignored if metadata is not provided.False
: metadata is not requested and the meta-estimator will not pass it tofit
.None
: metadata is not requested, and the meta-estimator will raise an error if the user provides it.str
: metadata should be passed to the meta-estimator with this given alias instead of the original name.
The default (
sklearn.utils.metadata_routing.UNCHANGED
) retains the existing request. This allows you to change the request for some parameters and not others.New in version 1.3.
Note
This method is only relevant if this estimator is used as a sub-estimator of a meta-estimator, e.g. used inside a
pipeline.Pipeline
. Otherwise it has no effect.
- 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
- set_score_request(*, views: bool | None | str = '$UNCHANGED$') MPLS
Request metadata passed to the
score
method.Note that this method is only relevant if
enable_metadata_routing=True
(seesklearn.set_config()
). Please see User Guide on how the routing mechanism works.The options for each parameter are:
True
: metadata is requested, and passed toscore
if provided. The request is ignored if metadata is not provided.False
: metadata is not requested and the meta-estimator will not pass it toscore
.None
: metadata is not requested, and the meta-estimator will raise an error if the user provides it.str
: metadata should be passed to the meta-estimator with this given alias instead of the original name.
The default (
sklearn.utils.metadata_routing.UNCHANGED
) retains the existing request. This allows you to change the request for some parameters and not others.New in version 1.3.
Note
This method is only relevant if this estimator is used as a sub-estimator of a meta-estimator, e.g. used inside a
pipeline.Pipeline
. Otherwise it has no effect.
- set_transform_request(*, views: bool | None | str = '$UNCHANGED$') MPLS
Request metadata passed to the
transform
method.Note that this method is only relevant if
enable_metadata_routing=True
(seesklearn.set_config()
). Please see User Guide on how the routing mechanism works.The options for each parameter are:
True
: metadata is requested, and passed totransform
if provided. The request is ignored if metadata is not provided.False
: metadata is not requested and the meta-estimator will not pass it totransform
.None
: metadata is not requested, and the meta-estimator will raise an error if the user provides it.str
: metadata should be passed to the meta-estimator with this given alias instead of the original name.
The default (
sklearn.utils.metadata_routing.UNCHANGED
) retains the existing request. This allows you to change the request for some parameters and not others.New in version 1.3.
Note
This method is only relevant if this estimator is used as a sub-estimator of a meta-estimator, e.g. used inside a
pipeline.Pipeline
. Otherwise it has no effect.
- total_correlation_(views: Iterable[ndarray], **kwargs) ndarray
Returns the total correlation for each view
- 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:
correlation
- Return type:
numpy array of shape (n_views, latent_dimensions)
- total_correlation_captured(views: Iterable[ndarray], **kwargs)
Returns the total correlation captured by the latent space
- 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:
total_correlation_captured
- Return type:
- total_covariance_(views: Iterable[ndarray], **kwargs) float
Returns the total covariance
- 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:
covariance
- Return type:
- total_covariance_captured(views: Iterable[ndarray], **kwargs)
Returns the total covariance captured by the latent space
- 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:
total_covariance_captured
- Return type:
- total_variance_(views: Iterable[ndarray], **kwargs) ndarray
Returns the total variance for each view
- 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:
variance
- Return type:
numpy array of shape (n_views, latent_dimensions)
- total_variance_captured(views: Iterable[ndarray], **kwargs)
Returns the total variance captured by the latent space
- 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:
total_variance_captured
- Return type:
- class cca_zoo.linear.PCACCA(latent_dimensions=1, copy_data=True, random_state=None, c: Iterable[float] | float = None, eps=1e-09, percent_variance=0.99)[source]
Principal Component Analysis CCA
Data driven PCA on each view followed by CCA on the PCA components. Keep percentage of variance
- 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
- 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_metadata_routing()
Get metadata routing of this object.
Please check User Guide on how the routing mechanism works.
- Returns:
routing – A
MetadataRequest
encapsulating routing information.- Return type:
MetadataRequest
- 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_dimensions)
- 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_fit_request(*, views: bool | None | str = '$UNCHANGED$') PCACCA
Request metadata passed to the
fit
method.Note that this method is only relevant if
enable_metadata_routing=True
(seesklearn.set_config()
). Please see User Guide on how the routing mechanism works.The options for each parameter are:
True
: metadata is requested, and passed tofit
if provided. The request is ignored if metadata is not provided.False
: metadata is not requested and the meta-estimator will not pass it tofit
.None
: metadata is not requested, and the meta-estimator will raise an error if the user provides it.str
: metadata should be passed to the meta-estimator with this given alias instead of the original name.
The default (
sklearn.utils.metadata_routing.UNCHANGED
) retains the existing request. This allows you to change the request for some parameters and not others.New in version 1.3.
Note
This method is only relevant if this estimator is used as a sub-estimator of a meta-estimator, e.g. used inside a
pipeline.Pipeline
. Otherwise it has no effect.
- 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
- set_score_request(*, views: bool | None | str = '$UNCHANGED$') PCACCA
Request metadata passed to the
score
method.Note that this method is only relevant if
enable_metadata_routing=True
(seesklearn.set_config()
). Please see User Guide on how the routing mechanism works.The options for each parameter are:
True
: metadata is requested, and passed toscore
if provided. The request is ignored if metadata is not provided.False
: metadata is not requested and the meta-estimator will not pass it toscore
.None
: metadata is not requested, and the meta-estimator will raise an error if the user provides it.str
: metadata should be passed to the meta-estimator with this given alias instead of the original name.
The default (
sklearn.utils.metadata_routing.UNCHANGED
) retains the existing request. This allows you to change the request for some parameters and not others.New in version 1.3.
Note
This method is only relevant if this estimator is used as a sub-estimator of a meta-estimator, e.g. used inside a
pipeline.Pipeline
. Otherwise it has no effect.
- set_transform_request(*, views: bool | None | str = '$UNCHANGED$') PCACCA
Request metadata passed to the
transform
method.Note that this method is only relevant if
enable_metadata_routing=True
(seesklearn.set_config()
). Please see User Guide on how the routing mechanism works.The options for each parameter are:
True
: metadata is requested, and passed totransform
if provided. The request is ignored if metadata is not provided.False
: metadata is not requested and the meta-estimator will not pass it totransform
.None
: metadata is not requested, and the meta-estimator will raise an error if the user provides it.str
: metadata should be passed to the meta-estimator with this given alias instead of the original name.
The default (
sklearn.utils.metadata_routing.UNCHANGED
) retains the existing request. This allows you to change the request for some parameters and not others.New in version 1.3.
Note
This method is only relevant if this estimator is used as a sub-estimator of a meta-estimator, e.g. used inside a
pipeline.Pipeline
. Otherwise it has no effect.
- class cca_zoo.linear.PLS(latent_dimensions: int = 1, copy_data=True, random_state=None)[source]
A class used to fit a simple PLS model. This model finds the linear projections of two views that maximize their covariance.
Implements PLS by inheriting regularised CCA with maximal regularisation. This is equivalent to solving the following optimization problem:
\[ \begin{align}\begin{aligned}\begin{split}w_{opt}=\underset{w}{\mathrm{argmax}}\{ w_1^TX_1^TX_2w_2 \}\\\end{split}\\\text{subject to:}\\w_1^Tw_1=1\\w_2^Tw_2=1\end{aligned}\end{align} \]- Parameters:
- explained_covariance_(views: Iterable[ndarray], **kwargs) ndarray
Returns the total covariance for each view
- 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:
covariance
- Return type:
numpy array of shape (n_views, latent_dimensions)
- explained_covariance_cumulative_(views: Iterable[ndarray], **kwargs)
Returns the cumulative explained covariance for each view
- 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:
explained_covariance_cumulative_
- Return type:
numpy array of shape (n_views, latent_dimensions)
- explained_covariance_ratio_(views: Iterable[ndarray], **kwargs) ndarray
Returns the explained covariance ratio for each view
- 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:
explained_covariance_ratio_
- Return type:
numpy array of shape (n_views, latent_dimensions)
- explained_variance_(views: Iterable[ndarray], **kwargs) ndarray
Returns the total variance for each view
- 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:
variance
- Return type:
numpy array of shape (n_views, latent_dimensions)
- explained_variance_cumulative_(views: Iterable[ndarray], **kwargs) ndarray
Returns the cumulative explained variance for each view
- 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:
explained_variance_cumulative_
- Return type:
numpy array of shape (n_views, latent_dimensions)
- explained_variance_ratio_(views: Iterable[ndarray], **kwargs) ndarray
Returns the explained variance ratio for each view
- 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:
explained_variance_ratio
- Return type:
numpy array of shape (n_views, latent_dimensions)
- 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
- 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_metadata_routing()
Get metadata routing of this object.
Please check User Guide on how the routing mechanism works.
- Returns:
routing – A
MetadataRequest
encapsulating routing information.- Return type:
MetadataRequest
- 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_dimensions)
- 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_fit_request(*, views: bool | None | str = '$UNCHANGED$') PLS
Request metadata passed to the
fit
method.Note that this method is only relevant if
enable_metadata_routing=True
(seesklearn.set_config()
). Please see User Guide on how the routing mechanism works.The options for each parameter are:
True
: metadata is requested, and passed tofit
if provided. The request is ignored if metadata is not provided.False
: metadata is not requested and the meta-estimator will not pass it tofit
.None
: metadata is not requested, and the meta-estimator will raise an error if the user provides it.str
: metadata should be passed to the meta-estimator with this given alias instead of the original name.
The default (
sklearn.utils.metadata_routing.UNCHANGED
) retains the existing request. This allows you to change the request for some parameters and not others.New in version 1.3.
Note
This method is only relevant if this estimator is used as a sub-estimator of a meta-estimator, e.g. used inside a
pipeline.Pipeline
. Otherwise it has no effect.
- 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
- set_score_request(*, views: bool | None | str = '$UNCHANGED$') PLS
Request metadata passed to the
score
method.Note that this method is only relevant if
enable_metadata_routing=True
(seesklearn.set_config()
). Please see User Guide on how the routing mechanism works.The options for each parameter are:
True
: metadata is requested, and passed toscore
if provided. The request is ignored if metadata is not provided.False
: metadata is not requested and the meta-estimator will not pass it toscore
.None
: metadata is not requested, and the meta-estimator will raise an error if the user provides it.str
: metadata should be passed to the meta-estimator with this given alias instead of the original name.
The default (
sklearn.utils.metadata_routing.UNCHANGED
) retains the existing request. This allows you to change the request for some parameters and not others.New in version 1.3.
Note
This method is only relevant if this estimator is used as a sub-estimator of a meta-estimator, e.g. used inside a
pipeline.Pipeline
. Otherwise it has no effect.
- set_transform_request(*, views: bool | None | str = '$UNCHANGED$') PLS
Request metadata passed to the
transform
method.Note that this method is only relevant if
enable_metadata_routing=True
(seesklearn.set_config()
). Please see User Guide on how the routing mechanism works.The options for each parameter are:
True
: metadata is requested, and passed totransform
if provided. The request is ignored if metadata is not provided.False
: metadata is not requested and the meta-estimator will not pass it totransform
.None
: metadata is not requested, and the meta-estimator will raise an error if the user provides it.str
: metadata should be passed to the meta-estimator with this given alias instead of the original name.
The default (
sklearn.utils.metadata_routing.UNCHANGED
) retains the existing request. This allows you to change the request for some parameters and not others.New in version 1.3.
Note
This method is only relevant if this estimator is used as a sub-estimator of a meta-estimator, e.g. used inside a
pipeline.Pipeline
. Otherwise it has no effect.
- total_correlation_(views: Iterable[ndarray], **kwargs) ndarray
Returns the total correlation for each view
- 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:
correlation
- Return type:
numpy array of shape (n_views, latent_dimensions)
- total_correlation_captured(views: Iterable[ndarray], **kwargs)
Returns the total correlation captured by the latent space
- 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:
total_correlation_captured
- Return type:
- total_covariance_(views: Iterable[ndarray], **kwargs) float
Returns the total covariance
- 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:
covariance
- Return type:
- total_covariance_captured(views: Iterable[ndarray], **kwargs)
Returns the total covariance captured by the latent space
- 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:
total_covariance_captured
- Return type:
- total_variance_(views: Iterable[ndarray], **kwargs) ndarray
Returns the total variance for each view
- 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:
variance
- Return type:
numpy array of shape (n_views, latent_dimensions)
- total_variance_captured(views: Iterable[ndarray], **kwargs)
Returns the total variance captured by the latent space
- 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:
total_variance_captured
- Return type:
- class cca_zoo.linear.PLSEY(latent_dimensions: int = 1, copy_data=True, random_state=None, tol=1e-09, accept_sparse=None, batch_size=None, epochs=100, learning_rate=0.1, initialization: str | callable = 'random', dataloader_kwargs=None, optimizer_kwargs=None, convergence_checking=None, patience=10, track=None, verbose=False)[source]
- explained_covariance_(views: Iterable[ndarray], **kwargs) ndarray
Returns the total covariance for each view
- 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:
covariance
- Return type:
numpy array of shape (n_views, latent_dimensions)
- explained_covariance_cumulative_(views: Iterable[ndarray], **kwargs)
Returns the cumulative explained covariance for each view
- 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:
explained_covariance_cumulative_
- Return type:
numpy array of shape (n_views, latent_dimensions)
- explained_covariance_ratio_(views: Iterable[ndarray], **kwargs) ndarray
Returns the explained covariance ratio for each view
- 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:
explained_covariance_ratio_
- Return type:
numpy array of shape (n_views, latent_dimensions)
- explained_variance_(views: Iterable[ndarray], **kwargs) ndarray
Returns the total variance for each view
- 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:
variance
- Return type:
numpy array of shape (n_views, latent_dimensions)
- explained_variance_cumulative_(views: Iterable[ndarray], **kwargs) ndarray
Returns the cumulative explained variance for each view
- 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:
explained_variance_cumulative_
- Return type:
numpy array of shape (n_views, latent_dimensions)
- explained_variance_ratio_(views: Iterable[ndarray], **kwargs) ndarray
Returns the explained variance ratio for each view
- 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:
explained_variance_ratio
- Return type:
numpy array of shape (n_views, latent_dimensions)
- 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
- 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_metadata_routing()
Get metadata routing of this object.
Please check User Guide on how the routing mechanism works.
- Returns:
routing – A
MetadataRequest
encapsulating routing information.- Return type:
MetadataRequest
- 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_dimensions)
- 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_fit_request(*, views: bool | None | str = '$UNCHANGED$') PLSEY
Request metadata passed to the
fit
method.Note that this method is only relevant if
enable_metadata_routing=True
(seesklearn.set_config()
). Please see User Guide on how the routing mechanism works.The options for each parameter are:
True
: metadata is requested, and passed tofit
if provided. The request is ignored if metadata is not provided.False
: metadata is not requested and the meta-estimator will not pass it tofit
.None
: metadata is not requested, and the meta-estimator will raise an error if the user provides it.str
: metadata should be passed to the meta-estimator with this given alias instead of the original name.
The default (
sklearn.utils.metadata_routing.UNCHANGED
) retains the existing request. This allows you to change the request for some parameters and not others.New in version 1.3.
Note
This method is only relevant if this estimator is used as a sub-estimator of a meta-estimator, e.g. used inside a
pipeline.Pipeline
. Otherwise it has no effect.
- 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
- set_score_request(*, views: bool | None | str = '$UNCHANGED$') PLSEY
Request metadata passed to the
score
method.Note that this method is only relevant if
enable_metadata_routing=True
(seesklearn.set_config()
). Please see User Guide on how the routing mechanism works.The options for each parameter are:
True
: metadata is requested, and passed toscore
if provided. The request is ignored if metadata is not provided.False
: metadata is not requested and the meta-estimator will not pass it toscore
.None
: metadata is not requested, and the meta-estimator will raise an error if the user provides it.str
: metadata should be passed to the meta-estimator with this given alias instead of the original name.
The default (
sklearn.utils.metadata_routing.UNCHANGED
) retains the existing request. This allows you to change the request for some parameters and not others.New in version 1.3.
Note
This method is only relevant if this estimator is used as a sub-estimator of a meta-estimator, e.g. used inside a
pipeline.Pipeline
. Otherwise it has no effect.
- set_transform_request(*, views: bool | None | str = '$UNCHANGED$') PLSEY
Request metadata passed to the
transform
method.Note that this method is only relevant if
enable_metadata_routing=True
(seesklearn.set_config()
). Please see User Guide on how the routing mechanism works.The options for each parameter are:
True
: metadata is requested, and passed totransform
if provided. The request is ignored if metadata is not provided.False
: metadata is not requested and the meta-estimator will not pass it totransform
.None
: metadata is not requested, and the meta-estimator will raise an error if the user provides it.str
: metadata should be passed to the meta-estimator with this given alias instead of the original name.
The default (
sklearn.utils.metadata_routing.UNCHANGED
) retains the existing request. This allows you to change the request for some parameters and not others.New in version 1.3.
Note
This method is only relevant if this estimator is used as a sub-estimator of a meta-estimator, e.g. used inside a
pipeline.Pipeline
. Otherwise it has no effect.
- total_correlation_(views: Iterable[ndarray], **kwargs) ndarray
Returns the total correlation for each view
- 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:
correlation
- Return type:
numpy array of shape (n_views, latent_dimensions)
- total_correlation_captured(views: Iterable[ndarray], **kwargs)
Returns the total correlation captured by the latent space
- 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:
total_correlation_captured
- Return type:
- total_covariance_(views: Iterable[ndarray], **kwargs) float
Returns the total covariance
- 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:
covariance
- Return type:
- total_covariance_captured(views: Iterable[ndarray], **kwargs)
Returns the total covariance captured by the latent space
- 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:
total_covariance_captured
- Return type:
- total_variance_(views: Iterable[ndarray], **kwargs) ndarray
Returns the total variance for each view
- 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:
variance
- Return type:
numpy array of shape (n_views, latent_dimensions)
- total_variance_captured(views: Iterable[ndarray], **kwargs)
Returns the total variance captured by the latent space
- 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:
total_variance_captured
- Return type:
- class cca_zoo.linear.PLSSVD(latent_dimensions: int = 1, copy_data=True, random_state=None, tol=1e-09, accept_sparse=None, batch_size=None, epochs=100, learning_rate=0.1, initialization: str | callable = 'random', dataloader_kwargs=None, optimizer_kwargs=None, convergence_checking=None, patience=10, track=None, verbose=False)[source]
- explained_covariance_(views: Iterable[ndarray], **kwargs) ndarray
Returns the total covariance for each view
- 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:
covariance
- Return type:
numpy array of shape (n_views, latent_dimensions)
- explained_covariance_cumulative_(views: Iterable[ndarray], **kwargs)
Returns the cumulative explained covariance for each view
- 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:
explained_covariance_cumulative_
- Return type:
numpy array of shape (n_views, latent_dimensions)
- explained_covariance_ratio_(views: Iterable[ndarray], **kwargs) ndarray
Returns the explained covariance ratio for each view
- 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:
explained_covariance_ratio_
- Return type:
numpy array of shape (n_views, latent_dimensions)
- explained_variance_(views: Iterable[ndarray], **kwargs) ndarray
Returns the total variance for each view
- 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:
variance
- Return type:
numpy array of shape (n_views, latent_dimensions)
- explained_variance_cumulative_(views: Iterable[ndarray], **kwargs) ndarray
Returns the cumulative explained variance for each view
- 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:
explained_variance_cumulative_
- Return type:
numpy array of shape (n_views, latent_dimensions)
- explained_variance_ratio_(views: Iterable[ndarray], **kwargs) ndarray
Returns the explained variance ratio for each view
- 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:
explained_variance_ratio
- Return type:
numpy array of shape (n_views, latent_dimensions)
- 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
- 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_metadata_routing()
Get metadata routing of this object.
Please check User Guide on how the routing mechanism works.
- Returns:
routing – A
MetadataRequest
encapsulating routing information.- Return type:
MetadataRequest
- 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_dimensions)
- 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_fit_request(*, views: bool | None | str = '$UNCHANGED$') PLSSVD
Request metadata passed to the
fit
method.Note that this method is only relevant if
enable_metadata_routing=True
(seesklearn.set_config()
). Please see User Guide on how the routing mechanism works.The options for each parameter are:
True
: metadata is requested, and passed tofit
if provided. The request is ignored if metadata is not provided.False
: metadata is not requested and the meta-estimator will not pass it tofit
.None
: metadata is not requested, and the meta-estimator will raise an error if the user provides it.str
: metadata should be passed to the meta-estimator with this given alias instead of the original name.
The default (
sklearn.utils.metadata_routing.UNCHANGED
) retains the existing request. This allows you to change the request for some parameters and not others.New in version 1.3.
Note
This method is only relevant if this estimator is used as a sub-estimator of a meta-estimator, e.g. used inside a
pipeline.Pipeline
. Otherwise it has no effect.
- 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
- set_score_request(*, views: bool | None | str = '$UNCHANGED$') PLSSVD
Request metadata passed to the
score
method.Note that this method is only relevant if
enable_metadata_routing=True
(seesklearn.set_config()
). Please see User Guide on how the routing mechanism works.The options for each parameter are:
True
: metadata is requested, and passed toscore
if provided. The request is ignored if metadata is not provided.False
: metadata is not requested and the meta-estimator will not pass it toscore
.None
: metadata is not requested, and the meta-estimator will raise an error if the user provides it.str
: metadata should be passed to the meta-estimator with this given alias instead of the original name.
The default (
sklearn.utils.metadata_routing.UNCHANGED
) retains the existing request. This allows you to change the request for some parameters and not others.New in version 1.3.
Note
This method is only relevant if this estimator is used as a sub-estimator of a meta-estimator, e.g. used inside a
pipeline.Pipeline
. Otherwise it has no effect.
- set_transform_request(*, views: bool | None | str = '$UNCHANGED$') PLSSVD
Request metadata passed to the
transform
method.Note that this method is only relevant if
enable_metadata_routing=True
(seesklearn.set_config()
). Please see User Guide on how the routing mechanism works.The options for each parameter are:
True
: metadata is requested, and passed totransform
if provided. The request is ignored if metadata is not provided.False
: metadata is not requested and the meta-estimator will not pass it totransform
.None
: metadata is not requested, and the meta-estimator will raise an error if the user provides it.str
: metadata should be passed to the meta-estimator with this given alias instead of the original name.
The default (
sklearn.utils.metadata_routing.UNCHANGED
) retains the existing request. This allows you to change the request for some parameters and not others.New in version 1.3.
Note
This method is only relevant if this estimator is used as a sub-estimator of a meta-estimator, e.g. used inside a
pipeline.Pipeline
. Otherwise it has no effect.
- total_correlation_(views: Iterable[ndarray], **kwargs) ndarray
Returns the total correlation for each view
- 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:
correlation
- Return type:
numpy array of shape (n_views, latent_dimensions)
- total_correlation_captured(views: Iterable[ndarray], **kwargs)
Returns the total correlation captured by the latent space
- 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:
total_correlation_captured
- Return type:
- total_covariance_(views: Iterable[ndarray], **kwargs) float
Returns the total covariance
- 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:
covariance
- Return type:
- total_covariance_captured(views: Iterable[ndarray], **kwargs)
Returns the total covariance captured by the latent space
- 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:
total_covariance_captured
- Return type:
- total_variance_(views: Iterable[ndarray], **kwargs) ndarray
Returns the total variance for each view
- 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:
variance
- Return type:
numpy array of shape (n_views, latent_dimensions)
- total_variance_captured(views: Iterable[ndarray], **kwargs)
Returns the total variance captured by the latent space
- 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:
total_variance_captured
- Return type:
- class cca_zoo.linear.PLSStochasticPower(latent_dimensions: int = 1, copy_data=True, random_state=None, tol=1e-09, accept_sparse=None, batch_size=None, epochs=100, learning_rate=0.1, initialization: str | callable = 'random', dataloader_kwargs=None, optimizer_kwargs=None, convergence_checking=None, patience=10, track=None, verbose=False)[source]
- explained_covariance_(views: Iterable[ndarray], **kwargs) ndarray
Returns the total covariance for each view
- 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:
covariance
- Return type:
numpy array of shape (n_views, latent_dimensions)
- explained_covariance_cumulative_(views: Iterable[ndarray], **kwargs)
Returns the cumulative explained covariance for each view
- 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:
explained_covariance_cumulative_
- Return type:
numpy array of shape (n_views, latent_dimensions)
- explained_covariance_ratio_(views: Iterable[ndarray], **kwargs) ndarray
Returns the explained covariance ratio for each view
- 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:
explained_covariance_ratio_
- Return type:
numpy array of shape (n_views, latent_dimensions)
- explained_variance_(views: Iterable[ndarray], **kwargs) ndarray
Returns the total variance for each view
- 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:
variance
- Return type:
numpy array of shape (n_views, latent_dimensions)
- explained_variance_cumulative_(views: Iterable[ndarray], **kwargs) ndarray
Returns the cumulative explained variance for each view
- 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:
explained_variance_cumulative_
- Return type:
numpy array of shape (n_views, latent_dimensions)
- explained_variance_ratio_(views: Iterable[ndarray], **kwargs) ndarray
Returns the explained variance ratio for each view
- 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:
explained_variance_ratio
- Return type:
numpy array of shape (n_views, latent_dimensions)
- 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
- 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_metadata_routing()
Get metadata routing of this object.
Please check User Guide on how the routing mechanism works.
- Returns:
routing – A
MetadataRequest
encapsulating routing information.- Return type:
MetadataRequest
- 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_dimensions)
- 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_fit_request(*, views: bool | None | str = '$UNCHANGED$') PLSStochasticPower
Request metadata passed to the
fit
method.Note that this method is only relevant if
enable_metadata_routing=True
(seesklearn.set_config()
). Please see User Guide on how the routing mechanism works.The options for each parameter are:
True
: metadata is requested, and passed tofit
if provided. The request is ignored if metadata is not provided.False
: metadata is not requested and the meta-estimator will not pass it tofit
.None
: metadata is not requested, and the meta-estimator will raise an error if the user provides it.str
: metadata should be passed to the meta-estimator with this given alias instead of the original name.
The default (
sklearn.utils.metadata_routing.UNCHANGED
) retains the existing request. This allows you to change the request for some parameters and not others.New in version 1.3.
Note
This method is only relevant if this estimator is used as a sub-estimator of a meta-estimator, e.g. used inside a
pipeline.Pipeline
. Otherwise it has no effect.
- 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
- set_score_request(*, views: bool | None | str = '$UNCHANGED$') PLSStochasticPower
Request metadata passed to the
score
method.Note that this method is only relevant if
enable_metadata_routing=True
(seesklearn.set_config()
). Please see User Guide on how the routing mechanism works.The options for each parameter are:
True
: metadata is requested, and passed toscore
if provided. The request is ignored if metadata is not provided.False
: metadata is not requested and the meta-estimator will not pass it toscore
.None
: metadata is not requested, and the meta-estimator will raise an error if the user provides it.str
: metadata should be passed to the meta-estimator with this given alias instead of the original name.
The default (
sklearn.utils.metadata_routing.UNCHANGED
) retains the existing request. This allows you to change the request for some parameters and not others.New in version 1.3.
Note
This method is only relevant if this estimator is used as a sub-estimator of a meta-estimator, e.g. used inside a
pipeline.Pipeline
. Otherwise it has no effect.
- set_transform_request(*, views: bool | None | str = '$UNCHANGED$') PLSStochasticPower
Request metadata passed to the
transform
method.Note that this method is only relevant if
enable_metadata_routing=True
(seesklearn.set_config()
). Please see User Guide on how the routing mechanism works.The options for each parameter are:
True
: metadata is requested, and passed totransform
if provided. The request is ignored if metadata is not provided.False
: metadata is not requested and the meta-estimator will not pass it totransform
.None
: metadata is not requested, and the meta-estimator will raise an error if the user provides it.str
: metadata should be passed to the meta-estimator with this given alias instead of the original name.
The default (
sklearn.utils.metadata_routing.UNCHANGED
) retains the existing request. This allows you to change the request for some parameters and not others.New in version 1.3.
Note
This method is only relevant if this estimator is used as a sub-estimator of a meta-estimator, e.g. used inside a
pipeline.Pipeline
. Otherwise it has no effect.
- total_correlation_(views: Iterable[ndarray], **kwargs) ndarray
Returns the total correlation for each view
- 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:
correlation
- Return type:
numpy array of shape (n_views, latent_dimensions)
- total_correlation_captured(views: Iterable[ndarray], **kwargs)
Returns the total correlation captured by the latent space
- 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:
total_correlation_captured
- Return type:
- total_covariance_(views: Iterable[ndarray], **kwargs) float
Returns the total covariance
- 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:
covariance
- Return type:
- total_covariance_captured(views: Iterable[ndarray], **kwargs)
Returns the total covariance captured by the latent space
- 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:
total_covariance_captured
- Return type:
- total_variance_(views: Iterable[ndarray], **kwargs) ndarray
Returns the total variance for each view
- 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:
variance
- Return type:
numpy array of shape (n_views, latent_dimensions)
- total_variance_captured(views: Iterable[ndarray], **kwargs)
Returns the total variance captured by the latent space
- 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:
total_variance_captured
- Return type:
- class cca_zoo.linear.PLS_ALS(latent_dimensions: int = 1, copy_data=True, random_state=None, tol=0.001, accept_sparse=None, epochs=100, initialization: str | callable = 'random', early_stopping=False, verbose=True)[source]
- 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
- 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_metadata_routing()
Get metadata routing of this object.
Please check User Guide on how the routing mechanism works.
- Returns:
routing – A
MetadataRequest
encapsulating routing information.- Return type:
MetadataRequest
- 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_dimensions)
- 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_fit_request(*, views: bool | None | str = '$UNCHANGED$') PLS_ALS
Request metadata passed to the
fit
method.Note that this method is only relevant if
enable_metadata_routing=True
(seesklearn.set_config()
). Please see User Guide on how the routing mechanism works.The options for each parameter are:
True
: metadata is requested, and passed tofit
if provided. The request is ignored if metadata is not provided.False
: metadata is not requested and the meta-estimator will not pass it tofit
.None
: metadata is not requested, and the meta-estimator will raise an error if the user provides it.str
: metadata should be passed to the meta-estimator with this given alias instead of the original name.
The default (
sklearn.utils.metadata_routing.UNCHANGED
) retains the existing request. This allows you to change the request for some parameters and not others.New in version 1.3.
Note
This method is only relevant if this estimator is used as a sub-estimator of a meta-estimator, e.g. used inside a
pipeline.Pipeline
. Otherwise it has no effect.
- 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
- set_score_request(*, views: bool | None | str = '$UNCHANGED$') PLS_ALS
Request metadata passed to the
score
method.Note that this method is only relevant if
enable_metadata_routing=True
(seesklearn.set_config()
). Please see User Guide on how the routing mechanism works.The options for each parameter are:
True
: metadata is requested, and passed toscore
if provided. The request is ignored if metadata is not provided.False
: metadata is not requested and the meta-estimator will not pass it toscore
.None
: metadata is not requested, and the meta-estimator will raise an error if the user provides it.str
: metadata should be passed to the meta-estimator with this given alias instead of the original name.
The default (
sklearn.utils.metadata_routing.UNCHANGED
) retains the existing request. This allows you to change the request for some parameters and not others.New in version 1.3.
Note
This method is only relevant if this estimator is used as a sub-estimator of a meta-estimator, e.g. used inside a
pipeline.Pipeline
. Otherwise it has no effect.
- set_transform_request(*, views: bool | None | str = '$UNCHANGED$') PLS_ALS
Request metadata passed to the
transform
method.Note that this method is only relevant if
enable_metadata_routing=True
(seesklearn.set_config()
). Please see User Guide on how the routing mechanism works.The options for each parameter are:
True
: metadata is requested, and passed totransform
if provided. The request is ignored if metadata is not provided.False
: metadata is not requested and the meta-estimator will not pass it totransform
.None
: metadata is not requested, and the meta-estimator will raise an error if the user provides it.str
: metadata should be passed to the meta-estimator with this given alias instead of the original name.
The default (
sklearn.utils.metadata_routing.UNCHANGED
) retains the existing request. This allows you to change the request for some parameters and not others.New in version 1.3.
Note
This method is only relevant if this estimator is used as a sub-estimator of a meta-estimator, e.g. used inside a
pipeline.Pipeline
. Otherwise it has no effect.
- class cca_zoo.linear.PRCCA(latent_dimensions: int = 1, copy_data=True, random_state=None, eps=0.001, c=0)[source]
Partially Regularized Canonical Correlation Analysis
- Parameters:
latent_dimensions (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 for reproducibility, by default None
eps (float, optional) – Tolerance for convergence, by default 1e-3
c (Union[Iterable[float], float], optional) – Regularisation parameter, by default None
References
Tuzhilina, Elena, Leonardo Tozzi, and Trevor Hastie. “Canonical correlation analysis in high dimensions with structured regularization.” Statistical Modelling (2021): 1471082X211041033.
- 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
- fit(views: Iterable[ndarray], y=None, idxs=None, **kwargs)[source]
- Parameters:
views (list/tuple of numpy arrays or array likes with the same number of rows (samples)) –
y (None) –
idxs (list/tuple of integers indicating which features from each view are the partially regularised features) –
kwargs (any additional keyword arguments required by the given model) –
- 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_metadata_routing()
Get metadata routing of this object.
Please check User Guide on how the routing mechanism works.
- Returns:
routing – A
MetadataRequest
encapsulating routing information.- Return type:
MetadataRequest
- 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_dimensions)
- 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_fit_request(*, idxs: bool | None | str = '$UNCHANGED$', views: bool | None | str = '$UNCHANGED$') PRCCA
Request metadata passed to the
fit
method.Note that this method is only relevant if
enable_metadata_routing=True
(seesklearn.set_config()
). Please see User Guide on how the routing mechanism works.The options for each parameter are:
True
: metadata is requested, and passed tofit
if provided. The request is ignored if metadata is not provided.False
: metadata is not requested and the meta-estimator will not pass it tofit
.None
: metadata is not requested, and the meta-estimator will raise an error if the user provides it.str
: metadata should be passed to the meta-estimator with this given alias instead of the original name.
The default (
sklearn.utils.metadata_routing.UNCHANGED
) retains the existing request. This allows you to change the request for some parameters and not others.New in version 1.3.
Note
This method is only relevant if this estimator is used as a sub-estimator of a meta-estimator, e.g. used inside a
pipeline.Pipeline
. Otherwise it has no effect.- Parameters:
- Returns:
self – The updated object.
- 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
- set_score_request(*, views: bool | None | str = '$UNCHANGED$') PRCCA
Request metadata passed to the
score
method.Note that this method is only relevant if
enable_metadata_routing=True
(seesklearn.set_config()
). Please see User Guide on how the routing mechanism works.The options for each parameter are:
True
: metadata is requested, and passed toscore
if provided. The request is ignored if metadata is not provided.False
: metadata is not requested and the meta-estimator will not pass it toscore
.None
: metadata is not requested, and the meta-estimator will raise an error if the user provides it.str
: metadata should be passed to the meta-estimator with this given alias instead of the original name.
The default (
sklearn.utils.metadata_routing.UNCHANGED
) retains the existing request. This allows you to change the request for some parameters and not others.New in version 1.3.
Note
This method is only relevant if this estimator is used as a sub-estimator of a meta-estimator, e.g. used inside a
pipeline.Pipeline
. Otherwise it has no effect.
- set_transform_request(*, views: bool | None | str = '$UNCHANGED$') PRCCA
Request metadata passed to the
transform
method.Note that this method is only relevant if
enable_metadata_routing=True
(seesklearn.set_config()
). Please see User Guide on how the routing mechanism works.The options for each parameter are:
True
: metadata is requested, and passed totransform
if provided. The request is ignored if metadata is not provided.False
: metadata is not requested and the meta-estimator will not pass it totransform
.None
: metadata is not requested, and the meta-estimator will raise an error if the user provides it.str
: metadata should be passed to the meta-estimator with this given alias instead of the original name.
The default (
sklearn.utils.metadata_routing.UNCHANGED
) retains the existing request. This allows you to change the request for some parameters and not others.New in version 1.3.
Note
This method is only relevant if this estimator is used as a sub-estimator of a meta-estimator, e.g. used inside a
pipeline.Pipeline
. Otherwise it has no effect.
- class cca_zoo.linear.PartialCCA(latent_dimensions: int = 1, copy_data=True, random_state=None, c: Iterable[float] | float = None, accept_sparse=None, eps: float = 1e-06, pca: bool = True)[source]
A class used to fit a partial CCA model. This model extends CCA to account for confounding variables that may affect the correlation between views.
\[ \begin{align}\begin{aligned}\begin{split}w_{opt}=\underset{w}{\mathrm{argmax}}\{ w_1^TX_1^TX_2w_2 \}\\\end{split}\\\text{subject to:}\\w_i^TX_i^TX_iw_i=1\\w_i^TX_i^TZ=0\end{aligned}\end{align} \]References
Rao, B. Raja. “Partial canonical correlations.” Trabajos de estadistica y de investigación operativa 20.2-3 (1969): 211-219.
Example
>>> from cca_zoo.linear import PartialCCA >>> X1 = np.random.rand(10,5) >>> X2 = np.random.rand(10,5) >>> partials = np.random.rand(10,3) >>> model = PartialCCA() >>> model.fit((X1,X2),partials=partials).score((X1,X2)) array([0.99993046])
- 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
- fit(views: Iterable[ndarray], y=None, partials=None, **kwargs)[source]
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_metadata_routing()
Get metadata routing of this object.
Please check User Guide on how the routing mechanism works.
- Returns:
routing – A
MetadataRequest
encapsulating routing information.- Return type:
MetadataRequest
- 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_dimensions)
- 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_fit_request(*, partials: bool | None | str = '$UNCHANGED$', views: bool | None | str = '$UNCHANGED$') PartialCCA
Request metadata passed to the
fit
method.Note that this method is only relevant if
enable_metadata_routing=True
(seesklearn.set_config()
). Please see User Guide on how the routing mechanism works.The options for each parameter are:
True
: metadata is requested, and passed tofit
if provided. The request is ignored if metadata is not provided.False
: metadata is not requested and the meta-estimator will not pass it tofit
.None
: metadata is not requested, and the meta-estimator will raise an error if the user provides it.str
: metadata should be passed to the meta-estimator with this given alias instead of the original name.
The default (
sklearn.utils.metadata_routing.UNCHANGED
) retains the existing request. This allows you to change the request for some parameters and not others.New in version 1.3.
Note
This method is only relevant if this estimator is used as a sub-estimator of a meta-estimator, e.g. used inside a
pipeline.Pipeline
. Otherwise it has no effect.- Parameters:
- Returns:
self – The updated object.
- 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
- set_score_request(*, views: bool | None | str = '$UNCHANGED$') PartialCCA
Request metadata passed to the
score
method.Note that this method is only relevant if
enable_metadata_routing=True
(seesklearn.set_config()
). Please see User Guide on how the routing mechanism works.The options for each parameter are:
True
: metadata is requested, and passed toscore
if provided. The request is ignored if metadata is not provided.False
: metadata is not requested and the meta-estimator will not pass it toscore
.None
: metadata is not requested, and the meta-estimator will raise an error if the user provides it.str
: metadata should be passed to the meta-estimator with this given alias instead of the original name.
The default (
sklearn.utils.metadata_routing.UNCHANGED
) retains the existing request. This allows you to change the request for some parameters and not others.New in version 1.3.
Note
This method is only relevant if this estimator is used as a sub-estimator of a meta-estimator, e.g. used inside a
pipeline.Pipeline
. Otherwise it has no effect.
- set_transform_request(*, partials: bool | None | str = '$UNCHANGED$', views: bool | None | str = '$UNCHANGED$') PartialCCA
Request metadata passed to the
transform
method.Note that this method is only relevant if
enable_metadata_routing=True
(seesklearn.set_config()
). Please see User Guide on how the routing mechanism works.The options for each parameter are:
True
: metadata is requested, and passed totransform
if provided. The request is ignored if metadata is not provided.False
: metadata is not requested and the meta-estimator will not pass it totransform
.None
: metadata is not requested, and the meta-estimator will raise an error if the user provides it.str
: metadata should be passed to the meta-estimator with this given alias instead of the original name.
The default (
sklearn.utils.metadata_routing.UNCHANGED
) retains the existing request. This allows you to change the request for some parameters and not others.New in version 1.3.
Note
This method is only relevant if this estimator is used as a sub-estimator of a meta-estimator, e.g. used inside a
pipeline.Pipeline
. Otherwise it has no effect.- Parameters:
- Returns:
self – The updated object.
- Return type:
- transform(views: Iterable[ndarray], partials=None, **kwargs)[source]
- 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.linear.SCCA_IPLS(latent_dimensions: int = 1, copy_data=True, random_state=None, tol=0.001, accept_sparse=None, epochs=100, initialization: str | callable = 'uniform', early_stopping=False, verbose=True, alpha=None, l1_ratio=1, positive=None, stochastic=False)[source]
- 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
- 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_metadata_routing()
Get metadata routing of this object.
Please check User Guide on how the routing mechanism works.
- Returns:
routing – A
MetadataRequest
encapsulating routing information.- Return type:
MetadataRequest
- 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_dimensions)
- 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_fit_request(*, views: bool | None | str = '$UNCHANGED$') SCCA_IPLS
Request metadata passed to the
fit
method.Note that this method is only relevant if
enable_metadata_routing=True
(seesklearn.set_config()
). Please see User Guide on how the routing mechanism works.The options for each parameter are:
True
: metadata is requested, and passed tofit
if provided. The request is ignored if metadata is not provided.False
: metadata is not requested and the meta-estimator will not pass it tofit
.None
: metadata is not requested, and the meta-estimator will raise an error if the user provides it.str
: metadata should be passed to the meta-estimator with this given alias instead of the original name.
The default (
sklearn.utils.metadata_routing.UNCHANGED
) retains the existing request. This allows you to change the request for some parameters and not others.New in version 1.3.
Note
This method is only relevant if this estimator is used as a sub-estimator of a meta-estimator, e.g. used inside a
pipeline.Pipeline
. Otherwise it has no effect.
- 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
- set_score_request(*, views: bool | None | str = '$UNCHANGED$') SCCA_IPLS
Request metadata passed to the
score
method.Note that this method is only relevant if
enable_metadata_routing=True
(seesklearn.set_config()
). Please see User Guide on how the routing mechanism works.The options for each parameter are:
True
: metadata is requested, and passed toscore
if provided. The request is ignored if metadata is not provided.False
: metadata is not requested and the meta-estimator will not pass it toscore
.None
: metadata is not requested, and the meta-estimator will raise an error if the user provides it.str
: metadata should be passed to the meta-estimator with this given alias instead of the original name.
The default (
sklearn.utils.metadata_routing.UNCHANGED
) retains the existing request. This allows you to change the request for some parameters and not others.New in version 1.3.
Note
This method is only relevant if this estimator is used as a sub-estimator of a meta-estimator, e.g. used inside a
pipeline.Pipeline
. Otherwise it has no effect.
- set_transform_request(*, views: bool | None | str = '$UNCHANGED$') SCCA_IPLS
Request metadata passed to the
transform
method.Note that this method is only relevant if
enable_metadata_routing=True
(seesklearn.set_config()
). Please see User Guide on how the routing mechanism works.The options for each parameter are:
True
: metadata is requested, and passed totransform
if provided. The request is ignored if metadata is not provided.False
: metadata is not requested and the meta-estimator will not pass it totransform
.None
: metadata is not requested, and the meta-estimator will raise an error if the user provides it.str
: metadata should be passed to the meta-estimator with this given alias instead of the original name.
The default (
sklearn.utils.metadata_routing.UNCHANGED
) retains the existing request. This allows you to change the request for some parameters and not others.New in version 1.3.
Note
This method is only relevant if this estimator is used as a sub-estimator of a meta-estimator, e.g. used inside a
pipeline.Pipeline
. Otherwise it has no effect.
- class cca_zoo.linear.SCCA_PMD(latent_dimensions: int = 1, copy_data=True, random_state=None, tol=0.001, accept_sparse=None, epochs=100, initialization: str | callable = 'pls', early_stopping=False, verbose=True, tau=None, positive=False)[source]
- 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
- 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_metadata_routing()
Get metadata routing of this object.
Please check User Guide on how the routing mechanism works.
- Returns:
routing – A
MetadataRequest
encapsulating routing information.- Return type:
MetadataRequest
- 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_dimensions)
- 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_fit_request(*, views: bool | None | str = '$UNCHANGED$') SCCA_PMD
Request metadata passed to the
fit
method.Note that this method is only relevant if
enable_metadata_routing=True
(seesklearn.set_config()
). Please see User Guide on how the routing mechanism works.The options for each parameter are:
True
: metadata is requested, and passed tofit
if provided. The request is ignored if metadata is not provided.False
: metadata is not requested and the meta-estimator will not pass it tofit
.None
: metadata is not requested, and the meta-estimator will raise an error if the user provides it.str
: metadata should be passed to the meta-estimator with this given alias instead of the original name.
The default (
sklearn.utils.metadata_routing.UNCHANGED
) retains the existing request. This allows you to change the request for some parameters and not others.New in version 1.3.
Note
This method is only relevant if this estimator is used as a sub-estimator of a meta-estimator, e.g. used inside a
pipeline.Pipeline
. Otherwise it has no effect.
- 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
- set_score_request(*, views: bool | None | str = '$UNCHANGED$') SCCA_PMD
Request metadata passed to the
score
method.Note that this method is only relevant if
enable_metadata_routing=True
(seesklearn.set_config()
). Please see User Guide on how the routing mechanism works.The options for each parameter are:
True
: metadata is requested, and passed toscore
if provided. The request is ignored if metadata is not provided.False
: metadata is not requested and the meta-estimator will not pass it toscore
.None
: metadata is not requested, and the meta-estimator will raise an error if the user provides it.str
: metadata should be passed to the meta-estimator with this given alias instead of the original name.
The default (
sklearn.utils.metadata_routing.UNCHANGED
) retains the existing request. This allows you to change the request for some parameters and not others.New in version 1.3.
Note
This method is only relevant if this estimator is used as a sub-estimator of a meta-estimator, e.g. used inside a
pipeline.Pipeline
. Otherwise it has no effect.
- set_transform_request(*, views: bool | None | str = '$UNCHANGED$') SCCA_PMD
Request metadata passed to the
transform
method.Note that this method is only relevant if
enable_metadata_routing=True
(seesklearn.set_config()
). Please see User Guide on how the routing mechanism works.The options for each parameter are:
True
: metadata is requested, and passed totransform
if provided. The request is ignored if metadata is not provided.False
: metadata is not requested and the meta-estimator will not pass it totransform
.None
: metadata is not requested, and the meta-estimator will raise an error if the user provides it.str
: metadata should be passed to the meta-estimator with this given alias instead of the original name.
The default (
sklearn.utils.metadata_routing.UNCHANGED
) retains the existing request. This allows you to change the request for some parameters and not others.New in version 1.3.
Note
This method is only relevant if this estimator is used as a sub-estimator of a meta-estimator, e.g. used inside a
pipeline.Pipeline
. Otherwise it has no effect.
- class cca_zoo.linear.SCCA_Parkhomenko(latent_dimensions: int = 1, copy_data=True, random_state=None, tol=0.001, accept_sparse=None, epochs=100, initialization: str | callable = 'pls', early_stopping=False, verbose=True, tau=None)[source]
- 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
- 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_metadata_routing()
Get metadata routing of this object.
Please check User Guide on how the routing mechanism works.
- Returns:
routing – A
MetadataRequest
encapsulating routing information.- Return type:
MetadataRequest
- 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_dimensions)
- 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_fit_request(*, views: bool | None | str = '$UNCHANGED$') SCCA_Parkhomenko
Request metadata passed to the
fit
method.Note that this method is only relevant if
enable_metadata_routing=True
(seesklearn.set_config()
). Please see User Guide on how the routing mechanism works.The options for each parameter are:
True
: metadata is requested, and passed tofit
if provided. The request is ignored if metadata is not provided.False
: metadata is not requested and the meta-estimator will not pass it tofit
.None
: metadata is not requested, and the meta-estimator will raise an error if the user provides it.str
: metadata should be passed to the meta-estimator with this given alias instead of the original name.
The default (
sklearn.utils.metadata_routing.UNCHANGED
) retains the existing request. This allows you to change the request for some parameters and not others.New in version 1.3.
Note
This method is only relevant if this estimator is used as a sub-estimator of a meta-estimator, e.g. used inside a
pipeline.Pipeline
. Otherwise it has no effect.
- 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
- set_score_request(*, views: bool | None | str = '$UNCHANGED$') SCCA_Parkhomenko
Request metadata passed to the
score
method.Note that this method is only relevant if
enable_metadata_routing=True
(seesklearn.set_config()
). Please see User Guide on how the routing mechanism works.The options for each parameter are:
True
: metadata is requested, and passed toscore
if provided. The request is ignored if metadata is not provided.False
: metadata is not requested and the meta-estimator will not pass it toscore
.None
: metadata is not requested, and the meta-estimator will raise an error if the user provides it.str
: metadata should be passed to the meta-estimator with this given alias instead of the original name.
The default (
sklearn.utils.metadata_routing.UNCHANGED
) retains the existing request. This allows you to change the request for some parameters and not others.New in version 1.3.
Note
This method is only relevant if this estimator is used as a sub-estimator of a meta-estimator, e.g. used inside a
pipeline.Pipeline
. Otherwise it has no effect.
- set_transform_request(*, views: bool | None | str = '$UNCHANGED$') SCCA_Parkhomenko
Request metadata passed to the
transform
method.Note that this method is only relevant if
enable_metadata_routing=True
(seesklearn.set_config()
). Please see User Guide on how the routing mechanism works.The options for each parameter are:
True
: metadata is requested, and passed totransform
if provided. The request is ignored if metadata is not provided.False
: metadata is not requested and the meta-estimator will not pass it totransform
.None
: metadata is not requested, and the meta-estimator will raise an error if the user provides it.str
: metadata should be passed to the meta-estimator with this given alias instead of the original name.
The default (
sklearn.utils.metadata_routing.UNCHANGED
) retains the existing request. This allows you to change the request for some parameters and not others.New in version 1.3.
Note
This method is only relevant if this estimator is used as a sub-estimator of a meta-estimator, e.g. used inside a
pipeline.Pipeline
. Otherwise it has no effect.
- class cca_zoo.linear.SCCA_Span(latent_dimensions: int = 1, epochs: int = 100, copy_data=True, initialization: str = 'pls', tol: float = 0.001, regularisation='l0', tau: Iterable[float | int] | float | int = None, rank=1, positive: Iterable[bool] | bool = None, random_state=None, verbose=True, early_stopping=False)[source]
Fits a Sparse CCA model using SpanCCA.
\[ \begin{align}\begin{aligned}\begin{split}w_{opt}=\underset{w}{\mathrm{argmax}}\{\sum_i\sum_{j\neq i} \|X_iw_i-X_jw_j\|^2 + \text{l1_ratio}\|w_i\|_1\}\\\end{split}\\\text{subject to:}\\w_i^TX_i^TX_iw_i=1\end{aligned}\end{align} \]References
Asteris, Megasthenis, et al. “A simple and provable algorithm for sparse diagonal CCA.” International Conference on Machine Learning. PMLR, 2016.
- 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
- 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_metadata_routing()
Get metadata routing of this object.
Please check User Guide on how the routing mechanism works.
- Returns:
routing – A
MetadataRequest
encapsulating routing information.- Return type:
MetadataRequest
- 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_dimensions)
- 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_fit_request(*, views: bool | None | str = '$UNCHANGED$') SCCA_Span
Request metadata passed to the
fit
method.Note that this method is only relevant if
enable_metadata_routing=True
(seesklearn.set_config()
). Please see User Guide on how the routing mechanism works.The options for each parameter are:
True
: metadata is requested, and passed tofit
if provided. The request is ignored if metadata is not provided.False
: metadata is not requested and the meta-estimator will not pass it tofit
.None
: metadata is not requested, and the meta-estimator will raise an error if the user provides it.str
: metadata should be passed to the meta-estimator with this given alias instead of the original name.
The default (
sklearn.utils.metadata_routing.UNCHANGED
) retains the existing request. This allows you to change the request for some parameters and not others.New in version 1.3.
Note
This method is only relevant if this estimator is used as a sub-estimator of a meta-estimator, e.g. used inside a
pipeline.Pipeline
. Otherwise it has no effect.
- 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
- set_score_request(*, views: bool | None | str = '$UNCHANGED$') SCCA_Span
Request metadata passed to the
score
method.Note that this method is only relevant if
enable_metadata_routing=True
(seesklearn.set_config()
). Please see User Guide on how the routing mechanism works.The options for each parameter are:
True
: metadata is requested, and passed toscore
if provided. The request is ignored if metadata is not provided.False
: metadata is not requested and the meta-estimator will not pass it toscore
.None
: metadata is not requested, and the meta-estimator will raise an error if the user provides it.str
: metadata should be passed to the meta-estimator with this given alias instead of the original name.
The default (
sklearn.utils.metadata_routing.UNCHANGED
) retains the existing request. This allows you to change the request for some parameters and not others.New in version 1.3.
Note
This method is only relevant if this estimator is used as a sub-estimator of a meta-estimator, e.g. used inside a
pipeline.Pipeline
. Otherwise it has no effect.
- set_transform_request(*, views: bool | None | str = '$UNCHANGED$') SCCA_Span
Request metadata passed to the
transform
method.Note that this method is only relevant if
enable_metadata_routing=True
(seesklearn.set_config()
). Please see User Guide on how the routing mechanism works.The options for each parameter are:
True
: metadata is requested, and passed totransform
if provided. The request is ignored if metadata is not provided.False
: metadata is not requested and the meta-estimator will not pass it totransform
.None
: metadata is not requested, and the meta-estimator will raise an error if the user provides it.str
: metadata should be passed to the meta-estimator with this given alias instead of the original name.
The default (
sklearn.utils.metadata_routing.UNCHANGED
) retains the existing request. This allows you to change the request for some parameters and not others.New in version 1.3.
Note
This method is only relevant if this estimator is used as a sub-estimator of a meta-estimator, e.g. used inside a
pipeline.Pipeline
. Otherwise it has no effect.
- class cca_zoo.linear.TCCA(latent_dimensions: int = 1, copy_data=True, random_state=None, c: Iterable[float] | float = None, accept_sparse=None, eps: float = 1e-06, pca: bool = True)[source]
A class used to fit TCCA model. This model extends MCCA to higher order correlations by using tensor products of the views.
The objective function of TCCA is:
\[ \begin{align}\begin{aligned}\begin{split}w_{opt}=\underset{w}{\mathrm{argmax}}\{ w_1^TX_1^T\otimes w_2^TX_2^T\otimes \cdots \otimes w_m^TX_m^Tw \}\\\end{split}\\\text{subject to:}\\w_i^TX_i^TX_iw_i=1\end{aligned}\end{align} \]where \(\otimes\) denotes the Kronecker product.
References
Kim, Tae-Kyun, Shu-Fai Wong, and Roberto Cipolla. “Tensor canonical correlation analysis for action classification.” 2007 IEEE Conference on Computer Vision and Pattern Recognition. IEEE, 2007
Examples
>>> from cca_zoo.linear import TCCA >>> rng=np.random.RandomState(0) >>> X1 = rng.random((10,5)) >>> X2 = rng.random((10,5)) >>> X3 = rng.random((10,5)) >>> model = TCCA() >>> model.fit((X1,X2,X3)).score((X1,X2,X3)) array([1.14595755])
- correlations(views: Iterable[ndarray], **kwargs)[source]
Predicts the correlation for the given data using the fit model
- 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
- 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
- fit(views: Iterable[ndarray], y=None, **kwargs)[source]
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_metadata_routing()
Get metadata routing of this object.
Please check User Guide on how the routing mechanism works.
- Returns:
routing – A
MetadataRequest
encapsulating routing information.- Return type:
MetadataRequest
- 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_dimensions)
- score(views: Iterable[ndarray], **kwargs)[source]
Returns the higher order correlations 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
- set_fit_request(*, views: bool | None | str = '$UNCHANGED$') TCCA
Request metadata passed to the
fit
method.Note that this method is only relevant if
enable_metadata_routing=True
(seesklearn.set_config()
). Please see User Guide on how the routing mechanism works.The options for each parameter are:
True
: metadata is requested, and passed tofit
if provided. The request is ignored if metadata is not provided.False
: metadata is not requested and the meta-estimator will not pass it tofit
.None
: metadata is not requested, and the meta-estimator will raise an error if the user provides it.str
: metadata should be passed to the meta-estimator with this given alias instead of the original name.
The default (
sklearn.utils.metadata_routing.UNCHANGED
) retains the existing request. This allows you to change the request for some parameters and not others.New in version 1.3.
Note
This method is only relevant if this estimator is used as a sub-estimator of a meta-estimator, e.g. used inside a
pipeline.Pipeline
. Otherwise it has no effect.
- 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
- set_score_request(*, views: bool | None | str = '$UNCHANGED$') TCCA
Request metadata passed to the
score
method.Note that this method is only relevant if
enable_metadata_routing=True
(seesklearn.set_config()
). Please see User Guide on how the routing mechanism works.The options for each parameter are:
True
: metadata is requested, and passed toscore
if provided. The request is ignored if metadata is not provided.False
: metadata is not requested and the meta-estimator will not pass it toscore
.None
: metadata is not requested, and the meta-estimator will raise an error if the user provides it.str
: metadata should be passed to the meta-estimator with this given alias instead of the original name.
The default (
sklearn.utils.metadata_routing.UNCHANGED
) retains the existing request. This allows you to change the request for some parameters and not others.New in version 1.3.
Note
This method is only relevant if this estimator is used as a sub-estimator of a meta-estimator, e.g. used inside a
pipeline.Pipeline
. Otherwise it has no effect.
- set_transform_request(*, views: bool | None | str = '$UNCHANGED$') TCCA
Request metadata passed to the
transform
method.Note that this method is only relevant if
enable_metadata_routing=True
(seesklearn.set_config()
). Please see User Guide on how the routing mechanism works.The options for each parameter are:
True
: metadata is requested, and passed totransform
if provided. The request is ignored if metadata is not provided.False
: metadata is not requested and the meta-estimator will not pass it totransform
.None
: metadata is not requested, and the meta-estimator will raise an error if the user provides it.str
: metadata should be passed to the meta-estimator with this given alias instead of the original name.
The default (
sklearn.utils.metadata_routing.UNCHANGED
) retains the existing request. This allows you to change the request for some parameters and not others.New in version 1.3.
Note
This method is only relevant if this estimator is used as a sub-estimator of a meta-estimator, e.g. used inside a
pipeline.Pipeline
. Otherwise it has no effect.
- class cca_zoo.linear.rCCA(latent_dimensions: int = 1, copy_data=True, random_state=None, c: Iterable[float] | float = None, accept_sparse=None, eps: float = 1e-06, pca: bool = True)[source]
A class used to fit Regularised CCA (canonical ridge) model. This model adds a regularization term to the CCA objective function to avoid overfitting and improve stability. It uses PCA to perform the optimization efficiently for high dimensional data.
The objective function of regularised CCA is:
\[ \begin{align}\begin{aligned}\begin{split}w_{opt}=\underset{w}{\mathrm{argmax}}\{ w_1^TX_1^TX_2w_2 \}\\\end{split}\\\text{subject to:}\\(1-c_1)w_1^TX_1^TX_1w_1+c_1w_1^Tw_1=n\\(1-c_2)w_2^TX_2^TX_2w_2+c_2w_2^Tw_2=n\end{aligned}\end{align} \]where \(c_i\) are the regularization parameters for each view.
References
Vinod, Hrishikesh _D. “Canonical ridge and econometrics of joint production.” Journal of econometrics 4.2 (1976): 147-166.
- 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
- 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_metadata_routing()
Get metadata routing of this object.
Please check User Guide on how the routing mechanism works.
- Returns:
routing – A
MetadataRequest
encapsulating routing information.- Return type:
MetadataRequest
- 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_dimensions)
- 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_fit_request(*, views: bool | None | str = '$UNCHANGED$') rCCA
Request metadata passed to the
fit
method.Note that this method is only relevant if
enable_metadata_routing=True
(seesklearn.set_config()
). Please see User Guide on how the routing mechanism works.The options for each parameter are:
True
: metadata is requested, and passed tofit
if provided. The request is ignored if metadata is not provided.False
: metadata is not requested and the meta-estimator will not pass it tofit
.None
: metadata is not requested, and the meta-estimator will raise an error if the user provides it.str
: metadata should be passed to the meta-estimator with this given alias instead of the original name.
The default (
sklearn.utils.metadata_routing.UNCHANGED
) retains the existing request. This allows you to change the request for some parameters and not others.New in version 1.3.
Note
This method is only relevant if this estimator is used as a sub-estimator of a meta-estimator, e.g. used inside a
pipeline.Pipeline
. Otherwise it has no effect.
- 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
- set_score_request(*, views: bool | None | str = '$UNCHANGED$') rCCA
Request metadata passed to the
score
method.Note that this method is only relevant if
enable_metadata_routing=True
(seesklearn.set_config()
). Please see User Guide on how the routing mechanism works.The options for each parameter are:
True
: metadata is requested, and passed toscore
if provided. The request is ignored if metadata is not provided.False
: metadata is not requested and the meta-estimator will not pass it toscore
.None
: metadata is not requested, and the meta-estimator will raise an error if the user provides it.str
: metadata should be passed to the meta-estimator with this given alias instead of the original name.
The default (
sklearn.utils.metadata_routing.UNCHANGED
) retains the existing request. This allows you to change the request for some parameters and not others.New in version 1.3.
Note
This method is only relevant if this estimator is used as a sub-estimator of a meta-estimator, e.g. used inside a
pipeline.Pipeline
. Otherwise it has no effect.
- set_transform_request(*, views: bool | None | str = '$UNCHANGED$') rCCA
Request metadata passed to the
transform
method.Note that this method is only relevant if
enable_metadata_routing=True
(seesklearn.set_config()
). Please see User Guide on how the routing mechanism works.The options for each parameter are:
True
: metadata is requested, and passed totransform
if provided. The request is ignored if metadata is not provided.False
: metadata is not requested and the meta-estimator will not pass it totransform
.None
: metadata is not requested, and the meta-estimator will raise an error if the user provides it.str
: metadata should be passed to the meta-estimator with this given alias instead of the original name.
The default (
sklearn.utils.metadata_routing.UNCHANGED
) retains the existing request. This allows you to change the request for some parameters and not others.New in version 1.3.
Note
This method is only relevant if this estimator is used as a sub-estimator of a meta-estimator, e.g. used inside a
pipeline.Pipeline
. Otherwise it has no effect.