Skip to content

danielvogler/dtw_metrics

Repository files navigation

dtw_metrics

Dynamic time warping metrics.

python 3.11 pre-commit pre-commit.ci status linter Code style: black Imports: isort pydocstyle License: MIT

Description

Dynamic time warping (DTW) is an algorithm used to measure similarity between different data series, which may vary in speed.

Setup

Makefile

Setup via Makefile:

  • Clone the repository first.

  • Help and overview of commands:

    make help
  • Setup (Create the venv, install libraries and pull minimal data setup):

    make setup
  • Activate Python venv:

    make venv
  • Clean project:

    make clean

Python venv (Poetry)

  • Poetry is used for the virtual Python environment.
    • Install python poetry:

      curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python

      or

      pip install --user poetry
    • Make sure that the virtual environment is installed in the root folder of this projects:

      poetry config virtualenvs.in-project true
    • Install dependencies:

      poetry install --no-root
    • Add packages: To add further packages, run:

      poetry add <package-name>

Code formatting

  • Formatting via pre-commit hook: Python code is formatted using pre-commit hooks.

  • Install pre-commit:

    pip install pre-commit

    or

    brew install pre-commit
  • Install pre-commit hooks from the config file .pre-commit-config.yaml

    pre-commit install
  • Run the pre-commit hooks:

    pre-commit run -a

Code testing

Testing is done with pytest. The pytest package is already installed in the poetry venv.

  • Run all tests:

    pytest
  • Run individual tests:

    pytest <path-to-test-files>

Usage

  • Example files in /examples/

Examples

Symmetric P1 step pattern

Example image Fig 1: Compared time series and warped sequence.

Example image Fig 2: Cost matrix and optimal warping path.

Example image Fig 3: Accumulated cost matrix and optimal warping path.

Symmetric P0 step pattern

Example image Fig 1: Compared time series and warped sequence.

Example image Fig 2: Cost matrix and optimal warping path.

Example image Fig 3: Accumulated cost matrix and optimal warping path.

References

About

Dynamic time warping metrics

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors