Skip to content

Instantly share code, notes, and snippets.

@jcheong0428
Last active November 25, 2021 16:14
Show Gist options
  • Select an option

  • Save jcheong0428/c183e91173676c1895901cec9f76b54b to your computer and use it in GitHub Desktop.

Select an option

Save jcheong0428/c183e91173676c1895901cec9f76b54b to your computer and use it in GitHub Desktop.
Dynamic Time Warping example
from dtw import dtw,accelerated_dtw
d1 = df['S1_Joy'].interpolate().values
d2 = df['S2_Joy'].interpolate().values
d, cost_matrix, acc_cost_matrix, path = accelerated_dtw(d1,d2, dist='euclidean')
plt.imshow(acc_cost_matrix.T, origin='lower', cmap='gray', interpolation='nearest')
plt.plot(path[0], path[1], 'w')
plt.xlabel('Subject1')
plt.ylabel('Subject2')
plt.title(f'DTW Minimum Path with minimum distance: {np.round(d,2)}')
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment