Install fastdtw via pip
masterYou can install the fastdtw package using pip:
pip install fastdtwrepository·master·Indexed 21 days ago
https://github.com/slaypni/fastdtwA Python implementation of the FastDTW algorithm that provides an approximate Dynamic Time Warping solution with linear O(N) time and memory complexity. It calculates the distance and optimal alignment path between two sequences using a provided distance function.
You can install the fastdtw package using pip:
pip install fastdtwThe fastdtw function implements an approximate Dynamic Time Warping algorithm with $O(N)$ time and memory complexity. It calculates the distance and the optimal alignment path between two sequences.
To use it, pass two arrays (e.g., NumPy arrays) and a distance function (such as scipy.spatial.distance.euclidean) to the fastdtw function.
import numpy as np
from scipy.spatial.distance import euclidean
from fastdtw import fastdtw
x = np.array([[1,1], [2,2], [3,3], [4,4], [5,5]])
y = np.array([[2,2], [3,3], [4,4]])
distance, path = fastdtw(x, y, dist=euclidean)
print(distance)