coco_pipe.transforms.EuclideanAlign#

class coco_pipe.transforms.EuclideanAlign(mode='coral', *, shrinkage=True, channel_axis=None)#

Bases: SubjectAlignment

Per-subject mean or CORAL alignment, including unseen subjects.

X is (window, feature) or tokens (window, ..., feature): a subject’s mean, and for "coral" its feature covariance, are taken over all its tokens. With channel_axis, each channel’s tokens are centered on their own mean, and "coral" whitens every channel with the subject’s one covariance of the centered tokens. With shrinkage, "coral" scales each subject’s output to the identity’s mean squared norm (the number of features), so it does not depend on how many samples the subject has. The output keeps the shape and float dtype of X.

Each subject loses its mean, so a trait constant within a subject (a diagnosis, age) is removed with it; and when a subject’s samples mix conditions in uneven shares, its reference moves with its share. Use it for targets that vary within a subject, or pass subject x condition as groups to take a reference per condition.

Parameters:
  • mode (str)

  • shrinkage (bool)

  • channel_axis (int | None)

name = 'identity'#
property label: str#

EaMean or EaCoral, followed by Ch with channel_axis.

Return type:

str

fit(X, y=None, groups=None)#
transform(X, groups=None)#
fit_transform(X, y=None, groups=None, **fit_params)#

Fit subject statistics and transform the same observations.

fingerprint()#
Return type:

str

fold_local: bool = False#
get_metadata_routing()#

Ask for each row’s subject in fit and transform, and for its condition in fit when fit takes one.

get_params(deep=True)#

Get parameters for this estimator.

Parameters:

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

Returns:

params – Parameter names mapped to their values.

Return type:

dict

set_fit_request(*, groups='$UNCHANGED$')#

Configure whether metadata should be requested to be passed to the fit method.

Note that this method is only relevant when this estimator is used as a sub-estimator within a meta-estimator and metadata routing is enabled with enable_metadata_routing=True (see sklearn.set_config()). Please check the User Guide on how the routing mechanism works.

The options for each parameter are:

  • True: metadata is requested, and passed to fit if provided. The request is ignored if metadata is not provided.

  • False: metadata is not requested and the meta-estimator will not pass it to fit.

  • 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.

Added in version 1.3.

Parameters:
  • groups (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for groups parameter in fit.

  • self (EuclideanAlign)

Returns:

self – The updated object.

Return type:

object

set_output(*, transform=None)#

Set output container.

Refer to the user guide for more details and Introducing the set_output API for an example on how to use the API.

Parameters:

transform ({"default", "pandas", "polars"}, default=None) –

Configure output of transform and fit_transform.

  • ”default”: Default output format of a transformer

  • ”pandas”: DataFrame output

  • ”polars”: Polars output

  • None: Transform configuration is unchanged

Added in version 1.4: “polars” option was added.

Returns:

self – Estimator instance.

Return type:

estimator instance

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_transform_request(*, groups='$UNCHANGED$')#

Configure whether metadata should be requested to be passed to the transform method.

Note that this method is only relevant when this estimator is used as a sub-estimator within a meta-estimator and metadata routing is enabled with enable_metadata_routing=True (see sklearn.set_config()). Please check the User Guide on how the routing mechanism works.

The options for each parameter are:

  • True: metadata is requested, and passed to transform if provided. The request is ignored if metadata is not provided.

  • False: metadata is not requested and the meta-estimator will not pass it to transform.

  • 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.

Added in version 1.3.

Parameters:
  • groups (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for groups parameter in transform.

  • self (EuclideanAlign)

Returns:

self – The updated object.

Return type:

object