pyriemann.embedding.locally_linear_embedding(X, *, n_components=2, n_neighbors=5, metric='riemann', reg=0.001)

Perform a 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 xi,

  1. find its k nearest neighbors KNN(xi),

  2. calculate the best reconstruction of xi based on its k-nearest neighbors (Eq.9 in [1]),

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

Xndarray, shape (n_matrices, n_channels, n_channels)

Set of SPD matrices.

n_componentsint, default=2

Dimensionality of projected space.

n_neighborsint, default=5

Number of neighbors for reconstruction of each point.

metric{‘riemann’, ‘logeuclid’, ‘euclid’}, default: ‘riemann’

Metric used for KNN and Kernel estimation.

regfloat, default=1e-3

Regularization parameter.

embdndarray, shape (n_matrices, n_components)

Locally linear embedding of matrices in X.


Error of the projected embedding.


New in version 0.3.


[1] (1,2)

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