pyriemann.embedding.locally_linear_embedding

pyriemann.embedding.locally_linear_embedding(X, *, n_components=2, n_neighbors=5, metric='riemann', kernel=None, 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.

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

Set of SPD matrices.

n_componentsint, default=2

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

n_neighborsint, default=5

Number of neighbors for reconstruction of each point. 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.

Returns:
embdndarray, shape (n_matrices, n_components)

Locally linear embedding of matrices in X.

errorfloat

Error of the projected embedding.

Notes

New in version 0.3.

References

[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