ddtw_pairwise_distance#
- ddtw_pairwise_distance(X: ndarray, y: ndarray = None, window: float = None) ndarray [source]#
Compute the ddtw pairwise distance between a set of time series.
- Parameters:
- X: np.ndarray, of shape (n_instances, n_channels, n_timepoints) or
(n_instances, n_timepoints)
A collection of time series instances.
- y: np.ndarray, of shape (m_instances, m_channels, m_timepoints) or
(m_instances, m_timepoints) or (m_timepoints,), default=None
A collection of time series instances.
- window: float, default=None
The window to use for the bounding matrix. If None, no bounding matrix is used.
- Returns:
- np.ndarray (n_instances, n_instances)
ddtw 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. If n_timepoints is less than 2.
Examples
>>> import numpy as np >>> from aeon.distances import ddtw_pairwise_distance >>> # Distance between each time series in a collection of time series >>> X = np.array([[[1, 2, 3]],[[49, 58, 61]], [[73, 82, 99]]]) >>> ddtw_pairwise_distance(X) array([[ 0. , 42.25, 100. ], [ 42.25, 0. , 12.25], [100. , 12.25, 0. ]])
>>> # Distance between two collections of time series >>> X = np.array([[[19, 12, 39]],[[40, 51, 69]], [[79, 28, 91]]]) >>> y = np.array([[[110, 15, 123]],[[14, 150, 116]], [[9917, 118, 29]]]) >>> ddtw_pairwise_distance(X, y) array([[2.09306250e+03, 8.46400000e+03, 5.43611290e+07], [3.24900000e+03, 6.52056250e+03, 5.45271481e+07], [4.73062500e+02, 1.34560000e+04, 5.40078010e+07]])
>>> X = np.array([[[10, 22, 399]],[[41, 500, 1316]], [[117, 18, 9]]]) >>> y_univariate = np.array([[100, 11, 199],[10, 15, 26], [170, 108, 1119]]) >>> ddtw_pairwise_distance(X, y_univariate) array([[ 15129. ], [322624. ], [ 3220.5625]])