Last active
November 25, 2021 16:14
-
-
Save jcheong0428/c183e91173676c1895901cec9f76b54b to your computer and use it in GitHub Desktop.
Dynamic Time Warping example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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