tslearn.metrics.sigma_gak

tslearn.metrics.sigma_gak(dataset, n_samples=100, random_state=None, be=None)[source]

Compute sigma value to be used for GAK.

This method was originally presented in [1].

Parameters:
datasetarray-like, shape=(n_ts, sz, d) or (n_ts, sz1) or (sz,)

A dataset of time series. If shape is (n_ts, sz), the dataset is composed of univariate time series. If shape is (sz,), the dataset is composed of a unique univariate time series.

n_samplesint (default: 100)

Number of samples on which median distance should be estimated.

random_stateinteger or numpy.RandomState or None (default: None)

The generator used to draw the samples. If an integer is given, it fixes the seed. Defaults to the global numpy random number generator.

beBackend object or string or None

Backend. If be is an instance of the class NumPyBackend or the string “numpy”, the NumPy backend is used. If be is an instance of the class PyTorchBackend or the string “pytorch”, the PyTorch backend is used. If be is None, the backend is determined by the input arrays. See our dedicated user-guide page for more information.

Returns:
float

Suggested bandwidth (\(\sigma\)) for the Global Alignment kernel.

See also

gak

Compute Global Alignment kernel

cdist_gak

Compute cross-similarity matrix using Global Alignment kernel

References

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

Examples

>>> dataset = [[1, 2, 2, 3], [1., 2., 3., 4.]]
>>> sigma_gak(dataset=dataset,
...           n_samples=200,
...           random_state=0)  
2.0...