-
Notifications
You must be signed in to change notification settings - Fork 123
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added subsequence alignment in fastdtw.py #27
base: master
Are you sure you want to change the base?
Conversation
@Sophie-Ha Thank you for sending PR.
|
@slaypni I added the tests. DTW in original FastDTW: The path starts in the green cell and ends in the blue cell Subsequence version: The path can start anywhere in the green row and end anywhere in the blue row as long as the other path constraints are fulfilled (e.g. not going backwards) I achieved this by setting the intermediate cost to zero for the complete 0th row instead of just the point (0,0). Then the costs for all cells in the current window are computed as normally. Instead of taking the path that ends in the top right corner, the algorithm takes the path with minimal cost across the complete top row. |
@Sophie-Ha Thank you for your explanation! As far as I understand it properly, shouldn't the result distance be 0? In [37]: x = [1, 2, 0, 1, 2]
In [38]: fastdtw_subsequence(x, [1, 3 ,1] + x + [3, 2, 1])
Out[38]: (2.0, [(0, 3), (1, 3), (2, 3), (3, 3), (4, 4)]) |
@slaypni Yes, the distance should be 0. |
@Sophie-Ha Does that mean it cannot actually start anywhere in the green row and end in the blue row unless |
@slaypni It can start anywhere, regardless of the radius. If the radius is too small the algorithm just might miss the optimal solution, but this is also the case for regular fastdtw. Since the endpoints are not fixed in the subsequence version the resulting variability from the optimal path can be higher. |
Modified fastdtw.py to allow subsequence alignment by creating a new version of __dtw with less restrictions