Fix ctw_path never iterating because the path was compared with itself (#728) - #730
Open
cpruijsen wants to merge 1 commit into
Open
Fix ctw_path never iterating because the path was compared with itself (#728)#730cpruijsen wants to merge 1 commit into
cpruijsen wants to merge 1 commit into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #730 +/- ##
==========================================
+ Coverage 95.96% 95.99% +0.03%
==========================================
Files 87 87
Lines 9259 9288 +29
==========================================
+ Hits 8885 8916 +31
+ Misses 374 372 -2 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #728.
Summary
ctw_pathcompared the current alignment path with itself, so the loop always stopped after the first DTW. The returned score was the identity-projection DTW;max_iterwas a no-op; the path and the score disagreed;verboseonly printed iteration 0.dtw_pathcall.fitthe canonical axes are rescaled so each warped view has unit standard deviation before DTW. That is also what stops the period-2 path cycle on the series from [WIP] ctw fixes #579 (the paper's alternation is monotonically decreasing; Zhou's MATLAB code stops on path stability, not cycle detection).What I chose, and the alternative. Path-stability stop plus unit-covariance rescaling of the existing sklearn object. Alternative: typo-only, as in #579, that iterates and fixes the four bullets above, but on PR 579's series the path cycles and
ctw(..., max_iter=2) != ctw(..., max_iter=3). Happy to drop the rescaling if you want the smaller diff, or to replace sklearn CCA with the paper's generalized eigenproblem if you want a stricter match.This comparison has been in
ctw.pysince CTW landed. Callers that treatedmetric="ctw"as DTW (including the k-neighbors unit test) will see different rankings; that is the bugfix.Test plan
ctw(..., max_iter=1)still equals DTW; defaultctwdoes not, on the issue's rotated 3-D seriesdtw_path(*cca.transform(s1, s2))max_iter=5equalsmax_iter=100on that series (path has stabilized)max_iter=2equalsmax_iter=3(no parity-dependent score)KNeighborsTimeSeries(metric="ctw")neighbor order is no longer identical to DTW