tslearn.metrics.lb_keogh¶

tslearn.metrics.
lb_keogh
(ts_query, ts_candidate=None, radius=1, envelope_candidate=None)[source]¶ Compute LB_Keogh.
LB_Keogh was originally presented in [1].
Parameters:  ts_query : arraylike
Query timeseries to compare to the envelope of the candidate.
 ts_candidate : arraylike or None (default: None)
Candidate timeseries. None means the envelope is provided via envelope_candidate parameter and hence does not need to be computed again.
 radius : int (default: 1)
Radius to be used for the envelope generation (the envelope at time index i will be generated based on all observations from the candidate time series at indices comprised between iradius and i+radius). Not used if ts_candidate is None.
 envelope_candidate: pair of arraylike (envelope_down, envelope_up) or None
 (default: None)
Precomputed envelope of the candidate time series. If set to None, it is computed based on ts_candidate.
Returns:  float
Distance between the query time series and the envelope of the candidate time series.
See also
lb_envelope
 Compute LB_Keoghrelated envelope
Notes
This method requires a ts_query and ts_candidate (or envelope_candidate, depending on the call) to be of equal size.
References
[1] Keogh, E. Exact indexing of dynamic time warping. In International Conference on Very Large Data Bases, 2002. pp 406417. Examples
>>> ts1 = [1, 2, 3, 2, 1] >>> ts2 = [0, 0, 0, 0, 0] >>> env_low, env_up = lb_envelope(ts1, radius=1) >>> lb_keogh(ts_query=ts2, ... envelope_candidate=(env_low, env_up)) # doctest: +ELLIPSIS 2.8284... >>> lb_keogh(ts_query=ts2, ... ts_candidate=ts1, ... radius=1) # doctest: +ELLIPSIS 2.8284...