lcss_distance#
- lcss_distance(x: ndarray, y: ndarray, window: float = None, epsilon: float = 1.0) float [source]#
Return the lcss distance between x and y.
LCSS attempts to find the longest common sequence between two time series and returns a value that is the percentage that longest common sequence assumes. Originally present in [1], LCSS is computed by matching indexes that are similar up until a defined threshold (epsilon).
The value returned will be between 0.0 and 1.0, where 0.0 means the two time series are exactly the same and 1.0 means they are complete opposites.
- Parameters:
- x: np.ndarray, of shape (n_channels, n_timepoints) or (n_timepoints,)
First time series.
- y: np.ndarray, of shape (m_channels, m_timepoints) or (m_timepoints,)
Second time series.
- windowfloat, defaults=None
The window to use for the bounding matrix. If None, no bounding matrix is used.
- epsilon: float, defaults=1.
Matching threshold to determine if two subsequences are considered close enough to be considered ‘common’. The default is 1.
- Returns:
- float
The lcss distance between x and y.
- Raises:
- ValueError
If x and y are not 1D or 2D arrays.
References
[1]M. Vlachos, D. Gunopoulos, and G. Kollios. 2002. “Discovering Similar Multidimensional Trajectories”, In Proceedings of the 18th International Conference on Data Engineering (ICDE ‘02). IEEE Computer Society, USA, 673.
Examples
>>> import numpy as np >>> from aeon.distances import lcss_distance >>> x = np.array([[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]]) >>> y = np.array([[11, 12, 13, 14, 15, 16, 17, 18, 19, 20]]) >>> dist = lcss_distance(x, y)