Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/nyan-left/dynamic-time-warping-ts
Dynamic time warping for TypeScript.
https://github.com/nyan-left/dynamic-time-warping-ts
Last synced: 21 days ago
JSON representation
Dynamic time warping for TypeScript.
- Host: GitHub
- URL: https://github.com/nyan-left/dynamic-time-warping-ts
- Owner: nyan-left
- License: mit
- Created: 2021-08-16T09:20:23.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2021-08-16T09:31:00.000Z (over 3 years ago)
- Last Synced: 2024-05-03T10:17:07.860Z (8 months ago)
- Language: TypeScript
- Size: 117 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# dynamic-time-warping-2
This is a typed version of the [github.com/GordonLesti/dynamic-time-warping](https://github.com/GordonLesti/dynamic-time-warping) package, initially forked by [fheyen](https://github.com/fheyen/dynamic-time-warping-2#readme).
## Install
`npm install dynamic-time-warping-ts`
## Usage
### Importing the package
```ts
import DynamicTimeWarping from "dynamic-time-warping-ts";
```### Initialization
`DynamicTimeWarping` needs two arrays containing objects of the the same type and function that calculates the distance
between two objects and returns a float.```javascript
const ser1 = [ 9, 93, 15, 19, 24 ];
const ser2 = [ 31, 97, 81, 82, 39 ];
const distFunc = ( a, b )=> Math.abs( a - b );const dtw = new DynamicTimeWarping(ser1, ser2, distFunc);
```### getDistance
Will return the distance of the dynamic time warping as float.
```javascript
// 108
const dist = dtw.getDistance();
```### getPath
Will return the path of the dynamic time warping as array of arrays with two integers.
```javascript
// [ [ 0, 0 ], [ 1, 1 ], [ 1, 2 ], [ 1, 3 ], [ 2, 4 ], [ 3, 4 ], [ 4, 4 ] ]
const dist = dtw.getPath();
```## Credits
- [Frank Heyen](https://github.com/fheyen/)
- [Gordon Lesti](https://github.com/GordonLesti/)
- All contributors## License
The MIT License (MIT). Please see [License File](LICENSE.md) for more information.