Note
This page is a reference documentation. It only explains the class signature, and not how to use it. Please refer to the What you really need to know section for the big picture.
julearn.transformers.CBPM¶
- class julearn.transformers.CBPM(significance_threshold=0.05, corr_method=<function pearsonr>, agg_method=<function sum>, corr_sign='posneg', n_jobs=None, verbose=0)¶
Transformer for connectome-based predictive modeling.
It aggregates all features significantly correlated to the target. The significant negative and positive correlations are aggregateed separately and non-significant ones are dropped.
The user can choose to use negative, positive or both correlations. In case that there are no significant correlations and the mean of the target will be returned as the only feature.
This transformer implements the procedure described in [1].
- Parameters:
significance_threshold (
float, default:0.05) – Threshold of p value.corr_method (
Callable, default:<function pearsonr at 0x7f02ac94a610>) – Callable which can be used to create tuple of arrays: (correlations, p values). Input has to be X, y.agg_method (
Callable, default:<function sum at 0x7f02ce52b430>) – Callable to aggregate the features. Has to follow np convention using axis.corr_sign – Which correlations should be used: Options are:
- Attributes:
- y_mean_np.array
Contains the mean of the target, to be used for the transformation in case that there are no significant correlations.
- used_corr_sign_str
This will show you whether pos, neg or posneg was applied.
- X_y_correlations_tuple(np.array, np.array)
Output of the corr_method applied to the target and the features.
- significant_mask_np.array of bools
Array of bools showing which of the original features had a significant correlation.
- pos_mask_np.array of bools
Array of bools showing which of the original features had a positive correlation.
- pos_significant_mask_np.array of bools
Array of bools showing which of the original features had a significant positive correlation.
- neg_significant_mask_np.array of bools
Array of bools showing which of the original features had a significant negative correlation.
- used_significant_mask_np.array of bools
Array of bools showing which of the original features will be used by this transformer.
References
[1]Shen, X., Finn, E., Scheinost, D. et al. Using connectome-based predictive modeling to predict individual behavior from brain connectivity. Nat Protoc 12, 506-518 (2017). https://doi.org/10.1038/nprot.2016.178
- __init__(significance_threshold=0.05, corr_method=<function pearsonr>, agg_method=<function sum>, corr_sign='posneg', n_jobs=None, verbose=0)¶
- fit(X, y)¶
Fit the transformer.
Compute the correlations of each feature to the target, threhsold and create the respective masks.
- transform(X)¶
Transform the data.
Replace each of the features that had a significant correlation on the training data with the mean of the features (mean is computed per sample).
- Parameters:
X (
ndarray) – Input features.- Returns:
The transformed features.
- aggregate(X, mask)¶
Aggregate.
- get_feature_names_out(input_features=None)¶
Get output feature names.
- fit_transform(X, y=None, **fit_params)¶
Fit to data, then transform it.
Fits transformer to X and y with optional parameters fit_params and returns a transformed version of X.
- Parameters:
X (array-like of shape (n_samples, n_features)) – Input samples.
y (array-like of shape (n_samples,) or (n_samples, n_outputs), default=None) – Target values (None for unsupervised transformations).
**fit_params (dict) – Additional fit parameters. Pass only if the estimator accepts additional params in its fit method.
- Returns:
Transformed array.
- get_metadata_routing()¶
Get metadata routing of this object.
Please check User Guide on how the routing mechanism works.
- Returns:
A
MetadataRequestencapsulating routing information.
- 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:
Parameter names mapped to their values.
- set_output(*, transform=None)¶
Set output container.
See Introducing the set_output API for an example on how to use the API.
- Parameters:
transform ({“default”, “pandas”, “polars”}, default=None, default:
None) – Configure output of transform and fit_transform.- Returns:
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:
Estimator instance.