{"id":13689458,"url":"https://github.com/pollen-robotics/dtw","last_synced_at":"2025-05-15T23:05:15.240Z","repository":{"id":19109596,"uuid":"22338296","full_name":"pollen-robotics/dtw","owner":"pollen-robotics","description":"DTW (Dynamic Time Warping) python module","archived":false,"fork":false,"pushed_at":"2024-03-29T11:30:12.000Z","size":196,"stargazers_count":1195,"open_issues_count":16,"forks_count":235,"subscribers_count":32,"default_branch":"master","last_synced_at":"2025-05-04T02:16:51.269Z","etag":null,"topics":["distance","distance-measures","distance-metric","dtw","python"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pollen-robotics.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2014-07-28T10:01:39.000Z","updated_at":"2025-05-03T15:41:58.000Z","dependencies_parsed_at":"2022-07-12T10:22:41.012Z","dependency_job_id":"1d4b5e86-1ba9-4b88-abb2-9bd95a085e6e","html_url":"https://github.com/pollen-robotics/dtw","commit_stats":{"total_commits":52,"total_committers":12,"mean_commits":4.333333333333333,"dds":"0.40384615384615385","last_synced_commit":"dd76da15558ff5040587bc3759503a3ebb4a2a65"},"previous_names":["pierre-rouanet/dtw"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pollen-robotics%2Fdtw","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pollen-robotics%2Fdtw/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pollen-robotics%2Fdtw/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pollen-robotics%2Fdtw/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pollen-robotics","download_url":"https://codeload.github.com/pollen-robotics/dtw/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254436944,"owners_count":22070946,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["distance","distance-measures","distance-metric","dtw","python"],"created_at":"2024-08-02T15:01:48.719Z","updated_at":"2025-05-15T23:05:14.999Z","avatar_url":"https://github.com/pollen-robotics.png","language":"Python","readme":"# [Dynamic Time Warping](https://en.wikipedia.org/wiki/Dynamic_time_warping) Python Module\n\n[![Build Status](https://travis-ci.org/pierre-rouanet/dtw.svg?branch=master)](https://travis-ci.org/pierre-rouanet/dtw)\n\nDynamic time warping is used as a similarity measured between temporal sequences. This package provides two implementations:\n\n* the basic version (see [here](https://en.wikipedia.org/wiki/Dynamic_time_warping)) for the algorithm\n* an accelerated version which relies on scipy cdist (see https://github.com/pierre-rouanet/dtw/pull/8 for detail)\n\n```python\n\nimport numpy as np\n\n# We define two sequences x, y as numpy array\n# where y is actually a sub-sequence from x\nx = np.array([2, 0, 1, 1, 2, 4, 2, 1, 2, 0]).reshape(-1, 1)\ny = np.array([1, 1, 2, 4, 2, 1, 2, 0]).reshape(-1, 1)\n\nfrom dtw import dtw\n\nmanhattan_distance = lambda x, y: np.abs(x - y)\n\nd, cost_matrix, acc_cost_matrix, path = dtw(x, y, dist=manhattan_distance)\n\nprint(d)\n\u003e\u003e\u003e 2.0 # Only the cost for the insertions is kept\n\n# You can also visualise the accumulated cost and the shortest path\nimport matplotlib.pyplot as plt\n\nplt.imshow(acc_cost_matrix.T, origin='lower', cmap='gray', interpolation='nearest')\nplt.plot(path[0], path[1], 'w')\nplt.show()\n\n```\nResult of the accumulated cost matrix and the shortest path (in white) found:\n![Acc cost matrix and shortest path](./acc.png)\n\n\n## Other examples are available as notebook\n\n* [the code above as a notebook](./examples/simple%20example.ipynb)\n* [a sound comparison based on DTW + MFCC](./examples/MFCC%20%2B%20DTW.ipynb)\n* [simple speech recognition](./examples/speech-recognition.ipynb)\n\n\n## Installation\n\n```\npython -m pip install dtw\n```\n\nIt is tested on Python 2.7, 3.4, 3.5 and 3.6. It requires numpy and scipy.\n","funding_links":[],"categories":["Python"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpollen-robotics%2Fdtw","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpollen-robotics%2Fdtw","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpollen-robotics%2Fdtw/lists"}