R = rpy2.robjects.r
DTW = importr('dtw')
idx = np.linspace(0, 2 * np.pi, 100)
template = np.cos(idx)
query = np.sin(idx) + np.array(R.runif(100)) / 10
alignment = R.dtw(query, template, keep=True)
dist = alignment.rx('distance')[0][0]
print(dist)
Динамическая деформация времени в Python