lcss_cost_matrix¶
- lcss_cost_matrix(x: ndarray, y: ndarray, window: float | None = None, epsilon: float = 1.0, itakura_max_slope: float | None = None) ndarray [source]¶
Return the LCSS cost matrix between x and y.
- Parameters:
- xnp.ndarray
First time series, either univariate, shape
(n_timepoints,)
, or multivariate, shape(n_channels, n_timepoints)
.- ynp.ndarray
Second time series, either univariate, shape
(n_timepoints,)
, or multivariate, shape(n_channels, n_timepoints)
.- windowfloat, default=None
The window to use for the bounding matrix. If None, no bounding matrix is used.
- epsilonfloat, default=1.
Matching threshold to determine if two subsequences are considered close enough to be considered ‘common’. The default is 1.
- 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
The LCSS cost matrix between x and y.
- Raises:
- ValueError
If x and y are not 1D or 2D arrays.
Examples
>>> import numpy as np >>> from aeon.distances import lcss_cost_matrix >>> x = np.array([[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]]) >>> y = np.array([[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]]) >>> lcss_cost_matrix(x, y) array([[ 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [ 0., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1.], [ 0., 1., 2., 2., 2., 2., 2., 2., 2., 2., 2.], [ 0., 1., 2., 3., 3., 3., 3., 3., 3., 3., 3.], [ 0., 1., 2., 3., 4., 4., 4., 4., 4., 4., 4.], [ 0., 1., 2., 3., 4., 5., 5., 5., 5., 5., 5.], [ 0., 1., 2., 3., 4., 5., 6., 6., 6., 6., 6.], [ 0., 1., 2., 3., 4., 5., 6., 7., 7., 7., 7.], [ 0., 1., 2., 3., 4., 5., 6., 7., 8., 8., 8.], [ 0., 1., 2., 3., 4., 5., 6., 7., 8., 9., 9.], [ 0., 1., 2., 3., 4., 5., 6., 7., 8., 9., 10.]])