cdist_soft_dtw and cdist_soft_dtw_normalized return unsquared DTW for gamma=0

Open
#855 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
55/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
python

Research direction

Read the gamma-zero shortcut in _cdist_soft_dtw, where the issue says _cdist_dtw(...) is returned without squaring. Check the tests for cdist_soft_dtw and cdist_soft_dtw_normalized and run the relevant metric tests. Done means both functions return the expected squared DTW values for gamma=0; the issue points to proposed work in #851, so check its status before starting.

Written by the indexing model from the issue text.

Description

With gamma=0, cdist_soft_dtw and cdist_soft_dtw_normalized are documented to return squared DTW, as soft_dtw does, but they return plain DTW distances:

from tslearn.metrics import cdist_soft_dtw, cdist_soft_dtw_normalized

for metric in (cdist_soft_dtw, cdist_soft_dtw_normalized):
    print(metric([[0.], [2.]], gamma=0).tolist())
# [[0.0, 2.0], [2.0, 0.0]] for both; expected [[0.0, 4.0], [4.0, 0.0]]

The gamma-zero shortcut in _cdist_soft_dtw returns _cdist_dtw(...) without squaring it. A fix is proposed in #851.

Nathan, ChipLab

Dominant language
Python
Stars
3.2k
Forks
418
Avg merge
2d 14h
Merged PRs (30d)
24

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from tslearn-team/tslearn

All issues in tslearn-team/tslearn

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.