Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Inconsistent calculation results between tslearn, pyts and fastdtw

Aperta
#274 3 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 2 giorni

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
25/100
Tipo di issue
Bug
Chiarezza
Da chiarire
Stato di attività
Ferma
Stack tecnologico
numpy, python

Direzione di ricerca

Inizia eseguendo l’esempio Python fornito e confrontando le chiamate a tslearn.metrics.dtw e pyts.metrics.dtw per i vincoli FastDTW e Sakoe-Chiba. Esamina quindi i punti di ingresso DTW rilevanti e la gestione dei vincoli; il lavoro è completato quando viene determinato il comportamento previsto e le discrepanze vengono risolte o documentate.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

bug
Description

Please forgive me for my poor English since English is not my native language.

I have read the source code and Sakoe_Chiba band generation examples from tslearn, pyts. The generation manner of the Sakoe_Chiba seems different between pyts and tslearn, which leads to different calculation results when comparing 2 sequences with different lengths. I have also read the source code of fastdtw(https://pypi.org/project/fastdtw/) when the radius parameter is different, the calculation results between fastdtw and pyts are also varied.

Codes
import numpy as np
from tslearn.metrics import dtw as ts_dtw
from pyts.metrics import dtw as py_dtw
from fastdtw import fastdtw

if __name == "__main__":
    np.random.seed(2020)
    seq_0 = np.random.randn(140)
    seq_1 = np.random.randn(50)

    # Experiment 1: Different DTW caculation(Consistent)
    # [INFO] DTW Calculation:
    # -- tslearn dtw: 8.26240
    # -- pyts dtw: 8.26240
    print("[INFO] DTW Calculation:")
    print("-- tslearn dtw: {:.5f}".format(ts_dtw(seq_0, seq_1)))
    print("-- pyts dtw: {:.5f}".format(py_dtw(seq_0, seq_1)))
py_dtw
    # Experiment 2: FastDTW calculation(Inconsistent)
    # [INFO] FastDTW Calculation:
    # -- FastDTW results: 8.67608
    # -- pyts FastDTW: 9.12243
    print("\n[INFO] FastDTW Calculation:")
    print("-- FastDTW results: {:.5f}".format(
        np.sqrt(fastdtw(seq_0, seq_1, radius=2, dist=lambda x, y: (x-y)**2)[0])))
    print("-- pyts FastDTW: {:.5f}".format(
        py_dtw(seq_0, seq_1, method="fast", options={"radius": 2})))

    # Experiment 3: Sakoe_Chiba calculation(Inconsistent)
    # [INFO] Sakoe_Chiba Calculation:
    # -- tslearn Sakoe_Chiba dtw: 8.26240
    # -- pyts Sakoe_Chiba dtw: 10.49161
    print("\n[INFO] Sakoe_Chiba Calculation:")
    print("-- tslearn Sakoe_Chiba dtw: {:.5f}".format(
        ts_dtw(seq_0, seq_1, sakoe_chiba_radius=5)))
    print("-- pyts Sakoe_Chiba dtw: {:.5f}".format(
        py_dtw(seq_0, seq_1, method="sakoechiba",  options={"window_size": 5})))

    # Experiment 4: itakura calculation(In this example, they are consistent, however, I haven't read the source code yet)
    # [INFO] itakura Calculation:
    # -- tslearn itakura dtw: 8.51087
    # -- pyts itakura dtw: 8.51087
    print("\n[INFO] itakura Calculation:")
    print("-- tslearn itakura dtw: {:.5f}".format(
        ts_dtw(seq_0, seq_1, itakura_max_slope=6)))
    print("-- pyts itakura dtw: {:.5f}".format(
        py_dtw(seq_0, seq_1, method="itakura",  options={"max_slope": 6})))

Versions

OS: Ubuntu 18.04.4 LTS
NumPy 1.18.1
SciPy 1.4.1
Scikit-Learn 0.22.1
Numba 0.49.1
Pyts 0.11.0
tslearn: '0.4.1'
fastdtw: See pypi

Lingua principale
Python
Stelle
3.2k
Fork
397
Merge medio
1g 19h
PR unite (30g)
17

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di tslearn-team/tslearn

Tutte le issue di tslearn-team/tslearn

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.