erp_pairwise_distance¶
- erp_pairwise_distance(X: ndarray | list[ndarray], y: ndarray | list[ndarray] | None = None, window: float | None = None, g: float = 0.0, g_arr: ndarray | None = None, itakura_max_slope: float | None = None) ndarray [source]¶
Compute the ERP pairwise distance between a set of time series.
The optimal value of g is selected from the range [σ/5, σ], where σ is the standard deviation of the training data. When there is > 1 channel, g should be a np.ndarray where the nth value is the standard deviation of the nth channel.
- 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 erp 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.0.
The reference value to penalise gaps. The default is 0.
- g_arrnp.ndarray, of shape (n_channels), default=None
Numpy array that must be the length of the number of channels in x and y.
- 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)
ERP 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 erp_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]]]) >>> erp_pairwise_distance(X) array([[ 0., 9., 18.], [ 9., 0., 9.], [18., 9., 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]]]) >>> erp_pairwise_distance(X, y) array([[30., 39., 48.], [21., 30., 39.], [12., 21., 30.]])
>>> X = np.array([[[1, 2, 3]],[[4, 5, 6]], [[7, 8, 9]]]) >>> y_univariate = np.array([11, 12, 13]) >>> erp_pairwise_distance(X, y_univariate) array([[30.], [21.], [12.]]) >>> # 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])] >>> erp_pairwise_distance(X) array([[ 0., 16., 44.], [16., 0., 28.], [44., 28., 0.]])