# dtaidistance!!!优选
from dtaidistance import dtw
# x
query = [1, 1, 2, 3, 2, 0]
# y
template = [0, 1, 1, 2, 3, 2, 1]
dtw.distance(query, template)
1.4142135623730951
s1 = np.array([1, 1, 2, 3, 2, 0], dtype=np.double)
s2 = np.array([0, 1, 1, 2, 3, 2, 1], dtype=np.double)
dtw.distance_fast(s1, s2, use_pruning=True)
1.4142135623730951
print(dtw.distance.__doc__)
from dtaidistance import dtw
s1 = [1, 1, 2, 3, 2, 0]
s2 = [0, 1, 1, 2, 3, 2, 1]
distance, paths = dtw.warping_paths(s1, s2)
print(distance)
print(paths)
from dtaidistance import dtw
from dtaidistance import dtw_visualisation as dtwvis
import random
import numpy as np
s1 = np.array([1, 1, 2, 3, 2, 0], dtype=np.double)
s2 = np.array([0, 1, 1, 2, 3, 2, 1], dtype=np.double)
distance, paths = dtw.warping_paths(s1, s2
#, window=25
#, psi=2
)
print(distance)
best_path = dtw.best_path(paths)# 最短路径
dtwvis.plot_warpingpaths(s1, s2, paths, best_path)# 制图
最新评论