coco_pipe.transforms.EuclideanAlign#
- class coco_pipe.transforms.EuclideanAlign(mode='coral', *, shrinkage=True, channel_axis=None)#
Bases:
SubjectAlignmentPer-subject mean or CORAL alignment, including unseen subjects.
Xis(window, feature)or tokens(window, ..., feature): a subject’s mean, and for"coral"its feature covariance, are taken over all its tokens. Withchannel_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. Withshrinkage,"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 ofX.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 conditionasgroupsto take a reference per condition.- name = 'identity'#
- 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.
- get_metadata_routing()#
Ask for each row’s subject in
fitandtransform, and for its condition infitwhenfittakes one.
- get_params(deep=True)#
Get parameters for this estimator.
- set_fit_request(*, groups='$UNCHANGED$')#
Configure whether metadata should be requested to be passed to the
fitmethod.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(seesklearn.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 tofitif 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.Added in version 1.3.
- Parameters:
groups (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for
groupsparameter infit.self (EuclideanAlign)
- Returns:
self – The updated object.
- Return type:
- 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
transformmethod.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(seesklearn.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 totransformif 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.Added in version 1.3.
- Parameters:
groups (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for
groupsparameter intransform.self (EuclideanAlign)
- Returns:
self – The updated object.
- Return type: