adtw_pairwise_distance(X: , y: = None, window: = None, itakura_max_slope: = None, warp_penalty: float = 1.0) [source]

Compute the ADTW pairwise distance between a set of time series.

Parameters:
Xnp.ndarray or List of np.ndarray

A collection of time series instances of shape (n_cases, n_timepoints) or (n_cases, n_channels, n_timepoints).

ynp.ndarray or List of np.ndarray or None, default=None

A single series or a collection of time series of shape (m_timepoints,) or (m_cases, m_timepoints) or (m_cases, m_channels, m_timepoints). If None, then the adtw pairwise distance between the instances of X is calculated.

windowfloat or None, default=None

The window to use for the bounding matrix. If None, no bounding matrix is used.

itakura_max_slopefloat, default=None

Maximum slope as a proportion of the number of time points used to create Itakura parallelogram on the bounding matrix. Must be between 0. and 1.

warp_penalty: float, default=1.0

Penalty for warping. A high value will mean less warping. warp less and if value is low then will encourage algorithm to warp more.

Returns:
np.ndarray

ADTW pairwise matrix between the instances of X of shape (n_cases, n_cases) or between X and y of shape (n_cases, n_cases).

Raises:
ValueError

If X is not 2D or 3D array and if y is not 1D, 2D or 3D arrays when passing y.

Examples

>>> import numpy as np
>>> # Distance between each time series in a collection of time series
>>> X = np.array([[[1, 2, 3]],[[4, 5, 6]], [[7, 8, 9]]])
array([[  0.,  27., 108.],
[ 27.,   0.,  27.],
[108.,  27.,   0.]])
>>> # Distance between two collections of time series
>>> X = np.array([[[1, 2, 3]],[[4, 5, 6]], [[7, 8, 9]]])
>>> y = np.array([[[11, 12, 13]],[[14, 15, 16]], [[17, 18, 19]]])
array([[300., 507., 768.],
[147., 300., 507.],
[ 48., 147., 300.]])
>>> X = np.array([[[1, 2, 3]],[[4, 5, 6]], [[7, 8, 9]]])
>>> y_univariate = np.array([11, 12, 13])