Skip to main content

Dynamic time warping metrics.

Project description

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dtwmetrics-0.0.4.tar.gz (8.9 kB view hashes)

Uploaded Source

Built Distribution

dtwmetrics-0.0.4-py3-none-any.whl (9.0 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page