brainspace.gradient.gradient.GradientMaps¶
-
class
brainspace.gradient.gradient.
GradientMaps
(n_components=10, approach='dm', kernel=None, alignment=None, random_state=None)[source]¶ Gradient maps.
Parameters: - n_components (int, optional) – Number of gradients. Default is 10.
- approach ({'dm', 'le', 'pca'} or object, optional) –
Embedding approach. Default is ‘dm’. It can be a string or instance:
- ’dm’ or
DiffusionMaps
: embedding using diffusion maps. - ’le’ or
LaplacianEigenmaps
: embedding using Laplacian eigenmaps. - ’pca’ or
PCAMaps
: embedding using PCA.
- ’dm’ or
- kernel (str, callable or None, optional) – Kernel function to build the affinity matrix. Possible options: {‘pearson’, ‘spearman’, ‘cosine’, ‘normalized_angle’, ‘gaussian’}. If callable, must receive a 2D array and return a 2D square array. If None, use input matrix. Default is None.
- alignment ({'procrustes', 'joint'}, object or None) –
Alignment approach. Only used when two or more datasets are provided. If None, no alignment is performed. If object, it accepts an instance of
ProcrustesAlignment
. Default is None.- If ‘procrustes’, datasets are aligned using generalized procrustes analysis.
- If ‘joint’, datasets are embedded simultaneously based on a joint affinity matrix built from the individual datasets. This option is only available for ‘dm’ and ‘le’ approaches.
- random_state (int or None, optional) – Random state. Default is None.
Variables: - lambdas (ndarray or list of arrays, shape = (n_components,)) – Eigenvalues for each datatset.
- gradients (ndarray or list of arrays, shape = (n_samples, n_components)) – Gradients (i.e., eigenvectors).
- aligned (None or list of arrays, shape = (n_samples, n_components)) – Aligned gradients. None if
alignment is None
or only one dataset is used.
-
__init__
(n_components=10, approach='dm', kernel=None, alignment=None, random_state=None)[source]¶ Initialize self. See help(type(self)) for accurate signature.
Methods
__init__
([n_components, approach, kernel, …])Initialize self. fit
(x[, gamma, sparsity, n_iter, reference])Compute gradients and alignment. get_params
([deep])Get parameters for this estimator. set_params
(**params)Set the parameters of this estimator. -
fit
(x, gamma=None, sparsity=0.9, n_iter=10, reference=None, **kwargs)[source]¶ Compute gradients and alignment.
Parameters: - x (ndarray or list of arrays, shape = (n_samples, n_feat)) – Input matrix or list of matrices.
- gamma (float or None, optional) – Inverse kernel width. Only used if
kernel == 'gaussian'
. If None,gamma=1/n_feat
. Default is None. - sparsity (float, optional) – Proportion of the smallest elements to zero-out for each row. Default is 0.9.
- n_iter (int, optional) – Number of iterations for procrustes alignment. Default is 10.
- reference (ndarray, shape = (n_samples, n_feat), optional) – Initial reference for procrustes alignments. Only used when
alignment == 'procrustes'
. Default is None. - kwargs (kwds, optional) – Additional keyword parameters passed to the embedding approach.
Returns: self (object) – Returns self.