tslearn.metrics.gak

tslearn.metrics.gak(s1, s2, sigma=1.0)[source]

Compute Global Alignment Kernel (GAK) between (possibly multidimensional) time series and return it.

It is not required that both time series share the same size, but they must be the same dimension. GAK was originally presented in [1]. This is a normalized version that ensures that \(k(x,x)=1\) for all \(x\) and \(k(x,y) \in [0, 1]\) for all \(x, y\).

Parameters:
s1

A time series

s2

Another time series

sigma : float (default 1.)

Bandwidth of the internal gaussian kernel used for GAK

Returns:
float

Kernel value

See also

cdist_gak
Compute cross-similarity matrix using Global Alignment kernel

References

[1]
  1. Cuturi, “Fast global alignment kernels,” ICML 2011.

Examples

>>> gak([1, 2, 3], [1., 2., 2., 3.], sigma=2.)  # doctest: +ELLIPSIS
0.839...
>>> gak([1, 2, 3], [1., 2., 2., 3., 4.])  # doctest: +ELLIPSIS
0.273...