lcss_distance#
- lcss_distance(x: ndarray, y: ndarray, window: float | None = None, itakura_max_slope: float | None = None, bounding_matrix: ndarray | None = None, epsilon: float = 1.0, **kwargs: Any) float [source]#
Compute the longest common subsequence (LCSS) score between two time series.
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 (1d or 2d array)
First time series.
- y: np.ndarray (1d or 2d array)
Second time series.
- window: float, defaults = None
Float that is the radius of the sakoe chiba window (if using Sakoe-Chiba lower bounding). Value must be between 0. and 1.
- itakura_max_slope: float, defaults = None
Gradient of the slope for itakura parallelogram (if using Itakura Parallelogram lower bounding). Value must be between 0. and 1.
- bounding_matrix: np.ndarray (2d of size mxn where m is len(x) and n is len(y)),
defaults = None
Custom bounding matrix to use. If defined then other lower_bounding params are ignored. The matrix should be structure so that indexes considered in bound should be the value 0. and indexes outside the bounding matrix should be infinity.
- epsilonfloat, defaults = 1.
Matching threshold to determine if two subsequences are considered close enough to be considered ‘common’.
- kwargs: Any
Extra kwargs.
- Returns:
- float
Lcss distance between x and y. 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.
- Raises:
- ValueError
If the sakoe_chiba_window_radius is not a float. If the itakura_max_slope is not a float. If the value of x or y provided is not a numpy array. If the value of x or y has more than 2 dimensions. If a metric string provided, and is not a defined valid string. If a metric object (instance of class) is provided and doesn’t inherit from NumbaDistance. If the metric type cannot be determined If both window and itakura_max_slope are set
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.