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.
Locally Linear Embedding (LLE) is a non-linear, neighborhood-preserving dimensionality reduction algorithm which consists of three main steps [1]. For each SPD matrix X[i]:
find its k-nearest neighbors k-NN(X[i]),
calculate the best reconstruction of X[i] based on its k-nearest neighbors (Eq.9 in [1]),
calculate a low-dimensional embedding for all matrices 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 ton_matrices - 1
.- n_neighborsint, 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 ton_matrices - 1
.- metricstring, default=”riemann”
Metric used for k-NN and kernel estimation. For the list of supported metrics, see
pyriemann.utils.kernel.kernel()
.- 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
Added 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