Skip to main content

A simple implementation of the soft-dtw algorithm in rust with python bindings

Project description

Soft-DTW Rust

EXPERIMENTAL implementation of the Soft-DTW algorithm in Rust. The project is built with maturin so it can be used also with Python.

Note that this is primarily an exercise to learn how to code in Rust and integrate Rust scripts in Python. I'm not pretending that this is 100% functional or correct. This implementation is not created to be used as a loss function. It is designed only to compute the soft-dtw distance between two signals. Also for now works only if the signals to compare have the same length. In future I could modify the algorithm to work with signals of different lengths. The distance between samples of the two signals is computed through the L-2 norm.

Installation

Method 1

Use the command pip install soft-dtw-rust

Method 2

  1. Download the repository and install maturin in your python environment (it is available both in conda and pip).
  2. Install the package in your python environment running the command maturin develop --release.
  3. Import the module soft_dtw_rust and call one of the two methods compute_sdtw_1d or compute_sdtw_2d. For both methods, you can pass the hyperparameter gamma. If you not pass it by default will be set to 1.

Use the library

Import the package soft_dtw_rust and call the function compute_sdtw_1d or compute_sdtw_2d. The differences between 1d and 2d version is described below.

Example with code

import soft_dtw_rust
x = np.random.rand(size)
y = np.random.rand(size)
output = soft_dtw_rust.compute_sdtw_1d(x, y, gamma)

A small example with synthetic data can be found inside the example folder.

Extra notes on 1d and 2d version

Note that compute_sdtw_1d is used to compute the difference between two 1d signals and return a single float 64 value.

Instead compute_sdtw_2d is used to compute the difference between two matrices of signals. Also in this case the output is a single float 64 value. The matrices must have the same shape and each row must contain a signal (an example could be a multi-channel EEG signal). In this case, the algorithm use the soft-dtw to compare the signal in the first row of the first matrix with the signal in the first row of the second matrix and so on. The output of the various comparisons is summed and used as the final output of the function. Optionally you could pass an extra parameter called average_along_channels. As the name suggests, in this case, the final output will be divided by the number of signals inside the matrices.

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

soft_dtw_rust-0.1.2.tar.gz (10.3 kB view hashes)

Uploaded Source

Built Distributions

soft_dtw_rust-0.1.2-pp310-pypy310_pp73-musllinux_1_2_x86_64.whl (438.7 kB view hashes)

Uploaded PyPy musllinux: musl 1.2+ x86-64

soft_dtw_rust-0.1.2-pp310-pypy310_pp73-musllinux_1_2_i686.whl (457.9 kB view hashes)

Uploaded PyPy musllinux: musl 1.2+ i686

soft_dtw_rust-0.1.2-pp310-pypy310_pp73-musllinux_1_2_armv7l.whl (536.1 kB view hashes)

Uploaded PyPy musllinux: musl 1.2+ ARMv7l

soft_dtw_rust-0.1.2-pp310-pypy310_pp73-musllinux_1_2_aarch64.whl (454.5 kB view hashes)

Uploaded PyPy musllinux: musl 1.2+ ARM64

soft_dtw_rust-0.1.2-pp310-pypy310_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (267.9 kB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ x86-64

soft_dtw_rust-0.1.2-pp310-pypy310_pp73-manylinux_2_17_s390x.manylinux2014_s390x.whl (328.9 kB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ s390x

soft_dtw_rust-0.1.2-pp310-pypy310_pp73-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl (306.1 kB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ ppc64le

soft_dtw_rust-0.1.2-pp310-pypy310_pp73-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (273.4 kB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ ARMv7l

soft_dtw_rust-0.1.2-pp310-pypy310_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (276.0 kB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ ARM64

soft_dtw_rust-0.1.2-pp310-pypy310_pp73-manylinux_2_5_i686.manylinux1_i686.whl (277.3 kB view hashes)

Uploaded PyPy manylinux: glibc 2.5+ i686

soft_dtw_rust-0.1.2-pp39-pypy39_pp73-musllinux_1_2_x86_64.whl (439.6 kB view hashes)

Uploaded PyPy musllinux: musl 1.2+ x86-64

soft_dtw_rust-0.1.2-pp39-pypy39_pp73-musllinux_1_2_i686.whl (458.5 kB view hashes)

Uploaded PyPy musllinux: musl 1.2+ i686

soft_dtw_rust-0.1.2-pp39-pypy39_pp73-musllinux_1_2_armv7l.whl (536.6 kB view hashes)

Uploaded PyPy musllinux: musl 1.2+ ARMv7l

soft_dtw_rust-0.1.2-pp39-pypy39_pp73-musllinux_1_2_aarch64.whl (455.1 kB view hashes)

Uploaded PyPy musllinux: musl 1.2+ ARM64

soft_dtw_rust-0.1.2-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (268.7 kB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ x86-64

soft_dtw_rust-0.1.2-pp39-pypy39_pp73-manylinux_2_17_s390x.manylinux2014_s390x.whl (330.2 kB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ s390x

soft_dtw_rust-0.1.2-pp39-pypy39_pp73-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl (306.9 kB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ ppc64le

soft_dtw_rust-0.1.2-pp39-pypy39_pp73-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (273.8 kB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ ARMv7l

soft_dtw_rust-0.1.2-pp39-pypy39_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (276.4 kB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ ARM64

soft_dtw_rust-0.1.2-pp39-pypy39_pp73-manylinux_2_5_i686.manylinux1_i686.whl (278.0 kB view hashes)

Uploaded PyPy manylinux: glibc 2.5+ i686

soft_dtw_rust-0.1.2-pp38-pypy38_pp73-musllinux_1_2_x86_64.whl (439.6 kB view hashes)

Uploaded PyPy musllinux: musl 1.2+ x86-64

soft_dtw_rust-0.1.2-pp38-pypy38_pp73-musllinux_1_2_i686.whl (458.5 kB view hashes)

Uploaded PyPy musllinux: musl 1.2+ i686

soft_dtw_rust-0.1.2-pp38-pypy38_pp73-musllinux_1_2_armv7l.whl (536.4 kB view hashes)

Uploaded PyPy musllinux: musl 1.2+ ARMv7l

soft_dtw_rust-0.1.2-pp38-pypy38_pp73-musllinux_1_2_aarch64.whl (455.1 kB view hashes)

Uploaded PyPy musllinux: musl 1.2+ ARM64

soft_dtw_rust-0.1.2-pp38-pypy38_pp73-manylinux_2_17_s390x.manylinux2014_s390x.whl (330.0 kB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ s390x

soft_dtw_rust-0.1.2-pp38-pypy38_pp73-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl (306.9 kB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ ppc64le

soft_dtw_rust-0.1.2-pp38-pypy38_pp73-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (273.7 kB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ ARMv7l

soft_dtw_rust-0.1.2-pp38-pypy38_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (276.5 kB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ ARM64

soft_dtw_rust-0.1.2-cp312-none-win_amd64.whl (140.7 kB view hashes)

Uploaded CPython 3.12 Windows x86-64

soft_dtw_rust-0.1.2-cp312-none-win32.whl (134.2 kB view hashes)

Uploaded CPython 3.12 Windows x86

soft_dtw_rust-0.1.2-cp312-cp312-musllinux_1_2_x86_64.whl (437.4 kB view hashes)

Uploaded CPython 3.12 musllinux: musl 1.2+ x86-64

soft_dtw_rust-0.1.2-cp312-cp312-musllinux_1_2_i686.whl (456.7 kB view hashes)

Uploaded CPython 3.12 musllinux: musl 1.2+ i686

soft_dtw_rust-0.1.2-cp312-cp312-musllinux_1_2_armv7l.whl (534.9 kB view hashes)

Uploaded CPython 3.12 musllinux: musl 1.2+ ARMv7l

soft_dtw_rust-0.1.2-cp312-cp312-musllinux_1_2_aarch64.whl (452.9 kB view hashes)

Uploaded CPython 3.12 musllinux: musl 1.2+ ARM64

soft_dtw_rust-0.1.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (266.6 kB view hashes)

Uploaded CPython 3.12 manylinux: glibc 2.17+ x86-64

soft_dtw_rust-0.1.2-cp312-cp312-manylinux_2_17_s390x.manylinux2014_s390x.whl (318.7 kB view hashes)

Uploaded CPython 3.12 manylinux: glibc 2.17+ s390x

soft_dtw_rust-0.1.2-cp312-cp312-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl (304.2 kB view hashes)

Uploaded CPython 3.12 manylinux: glibc 2.17+ ppc64le

soft_dtw_rust-0.1.2-cp312-cp312-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (272.2 kB view hashes)

Uploaded CPython 3.12 manylinux: glibc 2.17+ ARMv7l

soft_dtw_rust-0.1.2-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (274.4 kB view hashes)

Uploaded CPython 3.12 manylinux: glibc 2.17+ ARM64

soft_dtw_rust-0.1.2-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.whl (276.5 kB view hashes)

Uploaded CPython 3.12 manylinux: glibc 2.5+ i686

soft_dtw_rust-0.1.2-cp312-cp312-macosx_11_0_arm64.whl (234.8 kB view hashes)

Uploaded CPython 3.12 macOS 11.0+ ARM64

soft_dtw_rust-0.1.2-cp312-cp312-macosx_10_12_x86_64.whl (238.9 kB view hashes)

Uploaded CPython 3.12 macOS 10.12+ x86-64

soft_dtw_rust-0.1.2-cp311-none-win_amd64.whl (140.1 kB view hashes)

Uploaded CPython 3.11 Windows x86-64

soft_dtw_rust-0.1.2-cp311-none-win32.whl (133.8 kB view hashes)

Uploaded CPython 3.11 Windows x86

soft_dtw_rust-0.1.2-cp311-cp311-musllinux_1_2_x86_64.whl (437.7 kB view hashes)

Uploaded CPython 3.11 musllinux: musl 1.2+ x86-64

soft_dtw_rust-0.1.2-cp311-cp311-musllinux_1_2_i686.whl (456.7 kB view hashes)

Uploaded CPython 3.11 musllinux: musl 1.2+ i686

soft_dtw_rust-0.1.2-cp311-cp311-musllinux_1_2_armv7l.whl (534.8 kB view hashes)

Uploaded CPython 3.11 musllinux: musl 1.2+ ARMv7l

soft_dtw_rust-0.1.2-cp311-cp311-musllinux_1_2_aarch64.whl (453.0 kB view hashes)

Uploaded CPython 3.11 musllinux: musl 1.2+ ARM64

soft_dtw_rust-0.1.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (266.9 kB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

soft_dtw_rust-0.1.2-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl (324.7 kB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ s390x

soft_dtw_rust-0.1.2-cp311-cp311-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl (304.6 kB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ ppc64le

soft_dtw_rust-0.1.2-cp311-cp311-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (272.2 kB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ ARMv7l

soft_dtw_rust-0.1.2-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (274.7 kB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ ARM64

soft_dtw_rust-0.1.2-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.whl (276.5 kB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.5+ i686

soft_dtw_rust-0.1.2-cp311-cp311-macosx_11_0_arm64.whl (234.6 kB view hashes)

Uploaded CPython 3.11 macOS 11.0+ ARM64

soft_dtw_rust-0.1.2-cp311-cp311-macosx_10_12_x86_64.whl (239.1 kB view hashes)

Uploaded CPython 3.11 macOS 10.12+ x86-64

soft_dtw_rust-0.1.2-cp310-none-win_amd64.whl (140.2 kB view hashes)

Uploaded CPython 3.10 Windows x86-64

soft_dtw_rust-0.1.2-cp310-none-win32.whl (133.8 kB view hashes)

Uploaded CPython 3.10 Windows x86

soft_dtw_rust-0.1.2-cp310-cp310-musllinux_1_2_x86_64.whl (437.9 kB view hashes)

Uploaded CPython 3.10 musllinux: musl 1.2+ x86-64

soft_dtw_rust-0.1.2-cp310-cp310-musllinux_1_2_i686.whl (456.8 kB view hashes)

Uploaded CPython 3.10 musllinux: musl 1.2+ i686

soft_dtw_rust-0.1.2-cp310-cp310-musllinux_1_2_armv7l.whl (534.9 kB view hashes)

Uploaded CPython 3.10 musllinux: musl 1.2+ ARMv7l

soft_dtw_rust-0.1.2-cp310-cp310-musllinux_1_2_aarch64.whl (453.2 kB view hashes)

Uploaded CPython 3.10 musllinux: musl 1.2+ ARM64

soft_dtw_rust-0.1.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (267.1 kB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

soft_dtw_rust-0.1.2-cp310-cp310-manylinux_2_17_s390x.manylinux2014_s390x.whl (325.3 kB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ s390x

soft_dtw_rust-0.1.2-cp310-cp310-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl (304.8 kB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ ppc64le

soft_dtw_rust-0.1.2-cp310-cp310-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (272.2 kB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ ARMv7l

soft_dtw_rust-0.1.2-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (274.9 kB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ ARM64

soft_dtw_rust-0.1.2-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.whl (276.7 kB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.5+ i686

soft_dtw_rust-0.1.2-cp310-cp310-macosx_11_0_arm64.whl (234.7 kB view hashes)

Uploaded CPython 3.10 macOS 11.0+ ARM64

soft_dtw_rust-0.1.2-cp39-none-win_amd64.whl (140.2 kB view hashes)

Uploaded CPython 3.9 Windows x86-64

soft_dtw_rust-0.1.2-cp39-none-win32.whl (133.7 kB view hashes)

Uploaded CPython 3.9 Windows x86

soft_dtw_rust-0.1.2-cp39-cp39-musllinux_1_2_x86_64.whl (437.9 kB view hashes)

Uploaded CPython 3.9 musllinux: musl 1.2+ x86-64

soft_dtw_rust-0.1.2-cp39-cp39-musllinux_1_2_i686.whl (457.1 kB view hashes)

Uploaded CPython 3.9 musllinux: musl 1.2+ i686

soft_dtw_rust-0.1.2-cp39-cp39-musllinux_1_2_armv7l.whl (535.0 kB view hashes)

Uploaded CPython 3.9 musllinux: musl 1.2+ ARMv7l

soft_dtw_rust-0.1.2-cp39-cp39-musllinux_1_2_aarch64.whl (453.4 kB view hashes)

Uploaded CPython 3.9 musllinux: musl 1.2+ ARM64

soft_dtw_rust-0.1.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (267.0 kB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

soft_dtw_rust-0.1.2-cp39-cp39-manylinux_2_17_s390x.manylinux2014_s390x.whl (324.7 kB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ s390x

soft_dtw_rust-0.1.2-cp39-cp39-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl (304.5 kB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ ppc64le

soft_dtw_rust-0.1.2-cp39-cp39-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (272.4 kB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ ARMv7l

soft_dtw_rust-0.1.2-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (275.0 kB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ ARM64

soft_dtw_rust-0.1.2-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.whl (276.3 kB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.5+ i686

soft_dtw_rust-0.1.2-cp39-cp39-macosx_11_0_arm64.whl (234.9 kB view hashes)

Uploaded CPython 3.9 macOS 11.0+ ARM64

soft_dtw_rust-0.1.2-cp38-none-win_amd64.whl (140.1 kB view hashes)

Uploaded CPython 3.8 Windows x86-64

soft_dtw_rust-0.1.2-cp38-none-win32.whl (133.6 kB view hashes)

Uploaded CPython 3.8 Windows x86

soft_dtw_rust-0.1.2-cp38-cp38-musllinux_1_2_x86_64.whl (437.7 kB view hashes)

Uploaded CPython 3.8 musllinux: musl 1.2+ x86-64

soft_dtw_rust-0.1.2-cp38-cp38-musllinux_1_2_i686.whl (456.7 kB view hashes)

Uploaded CPython 3.8 musllinux: musl 1.2+ i686

soft_dtw_rust-0.1.2-cp38-cp38-musllinux_1_2_armv7l.whl (534.7 kB view hashes)

Uploaded CPython 3.8 musllinux: musl 1.2+ ARMv7l

soft_dtw_rust-0.1.2-cp38-cp38-musllinux_1_2_aarch64.whl (453.0 kB view hashes)

Uploaded CPython 3.8 musllinux: musl 1.2+ ARM64

soft_dtw_rust-0.1.2-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (266.9 kB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64

soft_dtw_rust-0.1.2-cp38-cp38-manylinux_2_17_s390x.manylinux2014_s390x.whl (324.5 kB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ s390x

soft_dtw_rust-0.1.2-cp38-cp38-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl (304.6 kB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ ppc64le

soft_dtw_rust-0.1.2-cp38-cp38-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (272.0 kB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ ARMv7l

soft_dtw_rust-0.1.2-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (274.7 kB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ ARM64

soft_dtw_rust-0.1.2-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.whl (276.2 kB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.5+ i686

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