spd_learn.functional.kernel_riemann#

spd_learn.functional.kernel_riemann(X, Y=None, *, Cref=None, reg=1e-10)[source]#

Affine-invariant Riemannian kernel between two sets of SPD matrices.

Affine-invariant Riemannian kernel matrix \(\mathbf{K}\) of two sets \(\mathbf{X}\) and \(\mathbf{Y}\) of SPD matrices in \(\mathbb{R}^{n \times n}\) on tangent space at \(\mathbf{C}_\text{ref}\) is calculated with pairwise inner products [1]:

\[\mathbf{K}_{i,j} = \text{tr}( \log( \mathbf{C}_\text{ref}^{-1/2} \mathbf{X}_i \mathbf{C}_\text{ref}^{-1/2} ) \log( \mathbf{C}_\text{ref}^{-1/2} \mathbf{Y}_j \mathbf{C}_\text{ref}^{-1/2}) )\]
Parameters:
  • X (ndarray, shape (n_matrices_X, n, n)) – First set of SPD matrices.

  • Y (None | ndarray, shape (n_matrices_Y, n, n), default=None) – Second set of SPD matrices. If None, Y is set to X.

  • Cref (None | ndarray, shape (n, n), default=None) – Reference SPD matrix. If None, Cref is calculated as the Riemannian mean of X, see pyriemann.geometry.mean.mean_riemann().

  • reg (float, default=1e-10) – When Y is None, regularization parameter to mitigate numerical errors in kernel matrix estimation, to provide a positive-definite kernel matrix.

Returns:

K – Affine-invariant Riemannian kernel matrix between X and Y.

Return type:

ndarray, shape (n_matrices_X, n_matrices_Y)

Notes

Added in version 0.3.

Changed in version 0.12: Add support for NumPy and PyTorch.

See also

kernel

References

[1]

Classification of covariance matrices using a Riemannian-based kernel for BCI applications A. Barachant, S. Bonnet, M. Congedo and C. Jutten. Neurocomputing, Elsevier, 2013, 112, pp.172-178.