wdtw_pairwise_distance

wdtw_pairwise_distance(X: ndarray | List[ndarray], y: ndarray | List[ndarray] | None = None, window: float | None = None, g: float = 0.05, itakura_max_slope: float | None = None) ndarray[source]

Compute the WDTW 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 wdtw pairwise distance between the instances of X is calculated.

windowfloat, default=None

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

gfloat, default=0.05

Constant that controls the level of penalisation for the points with larger phase difference. Default is 0.05.

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.

Returns:
np.ndarray (n_cases, n_cases)

WDTW pairwise matrix between the instances of X.

Raises:
ValueError

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

Examples

>>> import numpy as np
>>> from aeon.distances import wdtw_pairwise_distance
>>> # Distance between each time series in a collection of time series
>>> X = np.array([[[1, 2, 3]],[[4, 5, 6]], [[7, 8, 9]]])
>>> wdtw_pairwise_distance(X)
array([[ 0.        , 12.61266072, 51.97594869],
       [12.61266072,  0.        , 12.61266072],
       [51.97594869, 12.61266072,  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]]])
>>> wdtw_pairwise_distance(X, y)
array([[144.37763524, 243.99820355, 369.60674621],
       [ 70.74504127, 144.37763524, 243.99820355],
       [ 23.10042164,  70.74504127, 144.37763524]])
>>> X = np.array([[[1, 2, 3]],[[4, 5, 6]], [[7, 8, 9]]])
>>> y_univariate = np.array([11, 12, 13])
>>> wdtw_pairwise_distance(X, y_univariate)
array([[144.37763524],
       [ 70.74504127],
       [ 23.10042164]])
>>> # Distance between each TS in a collection of unequal-length time series
>>> X = [np.array([1, 2, 3]), np.array([4, 5, 6, 7]), np.array([8, 9, 10, 11, 12])]
>>> wdtw_pairwise_distance(X)
array([[  0.        ,  20.25043711, 139.70656066],
       [ 20.25043711,   0.        ,  39.64543037],
       [139.70656066,  39.64543037,   0.        ]])