msm_pairwise_distance#

msm_pairwise_distance(X: ndarray, y: ndarray = None, window: float = None, independent: bool = True, c: float = 1.0) ndarray[source]#

Compute the msm 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.

independent: bool, defaults=True

Whether to use the independent or dependent MSM distance. The default is True (to use independent).

c: float, defaults=1.

Cost for split or merge operation. Default is 1.

Returns:
np.ndarray (n_instances, n_instances)

msm 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 msm_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]]])
>>> msm_pairwise_distance(X)
array([[ 0.,  8., 12.],
       [ 8.,  0.,  8.],
       [12.,  8.,  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]]])
>>> msm_pairwise_distance(X, y)
array([[16., 19., 22.],
       [13., 16., 19.],
       [10., 13., 16.]])
>>> X = np.array([[[1, 2, 3]],[[4, 5, 6]], [[7, 8, 9]]])
>>> y_univariate = np.array([[11, 12, 13],[14, 15, 16], [17, 18, 19]])
>>> msm_pairwise_distance(X, y_univariate)
array([[16.],
       [13.],
       [10.]])