https://github.com/ymtoo/ts-dist
Time series distance measures
https://github.com/ymtoo/ts-dist
distance-measure dynamic-time-warping edit-distance-on-real-sequence longest-common-subsequence time-series
Last synced: 12 months ago
JSON representation
Time series distance measures
- Host: GitHub
- URL: https://github.com/ymtoo/ts-dist
- Owner: ymtoo
- Created: 2018-10-19T09:22:57.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2022-04-05T09:35:15.000Z (about 4 years ago)
- Last Synced: 2025-04-13T15:49:18.874Z (about 1 year ago)
- Topics: distance-measure, dynamic-time-warping, edit-distance-on-real-sequence, longest-common-subsequence, time-series
- Language: Python
- Homepage:
- Size: 17.6 KB
- Stars: 24
- Watchers: 2
- Forks: 9
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# ts-dist
The module contains Python implementations of distance measures between two real time series feature vectors. Faster Cython implementations are also provided.
## Distance measures
The following distance measures have been implemented.
* Dynamic Time Warping (DTW) [1]
* Longest Common Subsequence (LCSS) [2]
* Edit Distance on Real sequence (EDR) [3]
## Example
```python
import numpy as np
import pyximport; pyximport.install()
from ts_dist import dtw_dist as dtw_dist_py
from ts_dist import lcss_dist as lcss_dist_py
from ts_dist import edr_dist as edr_dist_py
from ts_dist_cy import dtw_dist as dtw_dist_cy
from ts_dist_cy import lcss_dist as lcss_dist_cy
from ts_dist_cy import edr_dist as edr_dist_cy
x = np.random.normal(0, 1, (1000))
y = np.random.normal(0, 1, (1000))
dtw_py = dtw_dist_py(x, y)
dtw_cy = dtw_dist_cy(x, y)
lcss_py = lcss_dist_py(x, y, delta=np.inf, epsilon=0.5)
lcss_cy = lcss_dist_cy(x, y, delta=np.inf, epsilon=0.5)
edr_py = edr_dist_py(x, y, epsilon=0.5)
edr_cy = edr_dist_cy(x, y, epsilon=0.5)
```
## Benchmark
```bash
$ python benchmark_ts_dist.py
Average time taken for dtw_dist_py: 0.15160710269992705
Average time taken for dtw_dist_cy: 0.022138842300046237
Average time taken for lcss_dist_py: 0.10573908710066462
Average time taken for lcss_dist_cy: 0.031031618600536603
Average time taken for edr_dist_py: 0.13265878920065005
Average time taken for edr_dist_cy: 0.03591040430037538
```
## Dependencies
* Python 3
* Cython
* Numpy
* Numba
## References
[1] https://www.cs.unm.edu/~mueen/DTW.pdf
[2] M. Vlachos, G. Kollios and D. Gunopulos, "Discovering Similar Multidimensional Trajectories", 2002.
[3] L Chen, MT Özsu, V Oria, "Robust and fast similarity search for moving object trajectories", 2005.