CharlesKZW / tsdistance

Comprehensive Python Library for Time Series Distance Measure
https://tsdistance.readthedocs.io/en/latest/
4 stars 0 forks source link
timeseries-analysis

tsdistance: time series distance measures

An open-source Python library that offers functions (a.k.a. distance measures) to compute the distance between time series. Distance measures in this library are suitable metrics for various time series machine learning tasks, including classification, clustering, motif discovery, similarity search, and more.

For details, please see the documentation.

Installation

from PyPi: python -m pip install tsdistance

This is alpha software with known Issues to be fixed, so use it with caution. Please provide feedback by openning Issues as they guide the developers on what to work on.

Examples

1. Compute the distance between two time series

>>> from tsdistance.elastic import lcss
>>> import numpy as np
>>> X = np.array([3, 4, 38, 4, 5])
>>> Y = np.array([0, 3, 4])
>>> lcss_dist = lcss(X, Y, epsilon = 0.7)
>>> lcss_dist

>>> 0.33333333333333337

2. Use a distance measure in a machine learning model (e.g. classfication)

>>> from tsdistance import OneNN
>>> model = OneNN(metric = 'lcss')
>>> model.fit(Coffee_train_X, Coffee_train_y)
>>> predicted_label = model.predict(Coffee_test_X)
>>> print('predicted_label: ', predicted_label)

>>> lb_predict:  [0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 1. 0. 0. 0. 0. 0. 0. 0. 0. 0.]

Available features

Elastic Measures

Lockstep Measures

Sliding Measures

Kernel Measures

Multivariate Distance Measures