wannesm / dtaidistance

Time series distances: Dynamic Time Warping (fast DTW implementation in C)
Other
1.08k stars 184 forks source link

Different results between Fedora and raspberry pi #187

Closed MalcolmMielle closed 1 year ago

MalcolmMielle commented 1 year ago

I'm having trouble with unit tests that pass on a "normal" fedora machine but fail on Ubuntu on a Raspberry pi 4.

I have narrowed it down to warping_paths` returning different values on each machine. I'm using dtaidistance 2.3.10 on both machine running python 3.10. Any idea what would create this behavior?

I'm using the code in this repo and run the test def test_probabilistic_encoding(self). By putting breakpoints I can see here line 90 that warping path return path with different sizes when given the same input. On raspberry pi, the final array is much smaller.

wannesm commented 1 year ago

The matrix returned on line 90 by _, paths = dtw_ndim.warping_paths(tcp_ref, trajectory.tcp) is always of shape (len(tcp_ref) + 1, len(trajectory.tcp) + 1). Can you share the shape in both cases? Are the values inside the matrices also different (if they appear random, it's probably an initialization issue)?

If tcp_ref is different on both platforms, there might be an issue earlier, e.g. when calling dtw.distance_matrix_fast. Is the output of this method the same on both platforms (assuming the input is the same)?

MalcolmMielle commented 1 year ago

I think I have pin pointed the error more accuratly. The trajectories that are aligned are extracted from three files. The order of those files is not the same between Raspberry pi and Fedora. I align all trajectories to a reference trajectory that is arbitrarly chosen. Luckily the reference is the same on both machine. But then the reference is aligned to one of the trajectories and itś a different one on each machine leading to an aligned reference that is a different length on both machines. Putting the files in the correct order actually solves the problem.

Sorry for the noise and thanks for giving pointer at what to look, it really helped!

Maybe that strategy to align multiple trajectories is not the best one and I should use one that is more robust.