pyriemann.embedding.LocallyLinearEmbedding

class pyriemann.embedding.LocallyLinearEmbedding(n_components=2, n_neighbors=5, metric='riemann', kernel=None, reg=0.001)

Locally Linear Embedding (LLE) of SPD matrices.

As proposed in [1], Locally Linear Embedding (LLE) is a non-linear, neighborhood-preserving dimensionality reduction algorithm which consists of three main steps. For each point x,

  1. find its k nearest neighbors KNN(x) and

  2. calculate the best reconstruction of x based on its KNN.

  3. Then calculate a low-dimensional embedding for all points based on the weights in step 2.

This implementation using SPD matrices is based on [2].

Parameters:
n_componentsint | None, default=2

Dimensionality of projected space. If None, n_components is set to n_matrices - 1.

n_neighborsint | None, default=5

Number of neighbors for reconstruction of each matrix. If None, all available matrices are used. If n_neighbors > n_matrices, n_neighbors is set to n_matrices - 1.

metric{“euclid”, “logeuclid”, “riemann”}, default: “riemann”

Metric used for KNN and Kernel estimation.

kernelcallable | None, default=None

Kernel function to use for the embedding. If None, the canonical kernel specified by the metric is used. Must be a function that takes the arguments (X, Cref, metric).

regfloat, default=1e-3

Regularization parameter.

Notes

New in version 0.3.

References

[1]

Nonlinear Dimensionality Reduction by Locally Linear Embedding S. Roweis and L. K. Saul, in Science, Vol 290, Issue 5500, pp. 2323-2326, 2000.

[2]

Clustering and dimensionality reduction on Riemannian manifolds A. Goh and R. Vidal, in 2008 IEEE Conference on Computer Vision and Pattern Recognition

Attributes:
embedding_ndarray, shape (n_matrices, n_components)

Stores the embedding vectors.

error_float

Reconstruction error associated with embedding_.

data_ndarray, shape (n_matrices, n_channels, n_channels)

Training data.

__init__(n_components=2, n_neighbors=5, metric='riemann', kernel=None, reg=0.001)
fit(X, y=None)

Fit the model from data in X.

Parameters:
Xndarray, shape (n_matrices, n_channels, n_channels)

Set of SPD matrices.

yNone

Not used, here for compatibility with sklearn API.

Returns:
selfobject

Returns the instance itself.

fit_transform(X, y=None)

Calculate the coordinates of the embedded points.

Parameters:
Xndarray, shape (n_matrices, n_channels, n_channels)

Set of SPD matrices.

yNone

Not used, here for compatibility with sklearn API.

Returns:
X_newndarray, shape (n_matrices, n_components)

Coordinates of embedded matrices.

get_metadata_routing()

Get metadata routing of this object.

Please check User Guide on how the routing mechanism works.

Returns:
routingMetadataRequest

A MetadataRequest encapsulating routing information.

get_params(deep=True)

Get parameters for this estimator.

Parameters:
deepbool, default=True

If True, will return the parameters for this estimator and contained subobjects that are estimators.

Returns:
paramsdict

Parameter names mapped to their values.

set_output(*, transform=None)

Set output container.

See sphx_glr_auto_examples_miscellaneous_plot_set_output.py for an example on how to use the API.

Parameters:
transform{“default”, “pandas”}, default=None

Configure output of transform and fit_transform.

  • “default”: Default output format of a transformer

  • “pandas”: DataFrame output

  • None: Transform configuration is unchanged

Returns:
selfestimator instance

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:
**paramsdict

Estimator parameters.

Returns:
selfestimator instance

Estimator instance.

transform(X, y=None)

Calculate embedding coordinates.

Calculate embedding coordinates for new data points based on fitted points.

Parameters:
Xndarray, shape (n_matrices, n_channels, n_channels)

Set of SPD matrices.

yNone

Not used, here for compatibility with sklearn API.

Returns:
X_newndarray, shape (n_matrices, n_components)

Coordinates of embedded matrices.