import numpy as np
x = np.array([2, 0, 1, 1, 2, 4, 2, 1, 2, 0]).reshape(-1, 1)
y = np.array([1, 1, 2, 4, 2, 1, 2, 0]).reshape(-1, 1)
print(x.shape)
from dtw import dtw
manhattan_distance = lambda x, y: np.abs(x – y)
d, cost_matrix, acc_cost_matrix, path = dtw(x, y, dist=manhattan_distance)
print(d)
import matplotlib.pyplot as plt
plt.imshow(acc_cost_matrix.T, origin=’lower’, cmap=’gray’, interpolation=’nearest’)
plt.plot(path[0], path[1], ‘w’)
plt.show()