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.

How to use

  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.

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 noted on python methods

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.1.tar.gz (10.2 kB view hashes)

Uploaded Source

Built Distributions

soft_dtw_rust-0.1.1-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.1-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.1-pp310-pypy310_pp73-musllinux_1_2_armv7l.whl (536.0 kB view hashes)

Uploaded PyPy musllinux: musl 1.2+ ARMv7l

soft_dtw_rust-0.1.1-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.1-pp310-pypy310_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (267.8 kB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ x86-64

soft_dtw_rust-0.1.1-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.1-pp310-pypy310_pp73-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl (306.0 kB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ ppc64le

soft_dtw_rust-0.1.1-pp310-pypy310_pp73-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (273.3 kB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ ARMv7l

soft_dtw_rust-0.1.1-pp310-pypy310_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (275.9 kB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ ARM64

soft_dtw_rust-0.1.1-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.1-pp39-pypy39_pp73-musllinux_1_2_x86_64.whl (439.5 kB view hashes)

Uploaded PyPy musllinux: musl 1.2+ x86-64

soft_dtw_rust-0.1.1-pp39-pypy39_pp73-musllinux_1_2_i686.whl (458.4 kB view hashes)

Uploaded PyPy musllinux: musl 1.2+ i686

soft_dtw_rust-0.1.1-pp39-pypy39_pp73-musllinux_1_2_armv7l.whl (536.5 kB view hashes)

Uploaded PyPy musllinux: musl 1.2+ ARMv7l

soft_dtw_rust-0.1.1-pp39-pypy39_pp73-musllinux_1_2_aarch64.whl (455.0 kB view hashes)

Uploaded PyPy musllinux: musl 1.2+ ARM64

soft_dtw_rust-0.1.1-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (268.6 kB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ x86-64

soft_dtw_rust-0.1.1-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.1-pp39-pypy39_pp73-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl (306.7 kB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ ppc64le

soft_dtw_rust-0.1.1-pp39-pypy39_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.1-pp39-pypy39_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (276.3 kB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ ARM64

soft_dtw_rust-0.1.1-pp39-pypy39_pp73-manylinux_2_5_i686.manylinux1_i686.whl (277.9 kB view hashes)

Uploaded PyPy manylinux: glibc 2.5+ i686

soft_dtw_rust-0.1.1-pp38-pypy38_pp73-musllinux_1_2_x86_64.whl (439.5 kB view hashes)

Uploaded PyPy musllinux: musl 1.2+ x86-64

soft_dtw_rust-0.1.1-pp38-pypy38_pp73-musllinux_1_2_i686.whl (458.4 kB view hashes)

Uploaded PyPy musllinux: musl 1.2+ i686

soft_dtw_rust-0.1.1-pp38-pypy38_pp73-musllinux_1_2_armv7l.whl (536.3 kB view hashes)

Uploaded PyPy musllinux: musl 1.2+ ARMv7l

soft_dtw_rust-0.1.1-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.1-pp38-pypy38_pp73-manylinux_2_17_s390x.manylinux2014_s390x.whl (329.9 kB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ s390x

soft_dtw_rust-0.1.1-pp38-pypy38_pp73-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl (306.8 kB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ ppc64le

soft_dtw_rust-0.1.1-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.1-pp38-pypy38_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.1-cp312-none-win_amd64.whl (141.2 kB view hashes)

Uploaded CPython 3.12 Windows x86-64

soft_dtw_rust-0.1.1-cp312-none-win32.whl (135.0 kB view hashes)

Uploaded CPython 3.12 Windows x86

soft_dtw_rust-0.1.1-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.1-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.1-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.1-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.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (266.5 kB view hashes)

Uploaded CPython 3.12 manylinux: glibc 2.17+ x86-64

soft_dtw_rust-0.1.1-cp312-cp312-manylinux_2_17_s390x.manylinux2014_s390x.whl (318.6 kB view hashes)

Uploaded CPython 3.12 manylinux: glibc 2.17+ s390x

soft_dtw_rust-0.1.1-cp312-cp312-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl (304.1 kB view hashes)

Uploaded CPython 3.12 manylinux: glibc 2.17+ ppc64le

soft_dtw_rust-0.1.1-cp312-cp312-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (272.1 kB view hashes)

Uploaded CPython 3.12 manylinux: glibc 2.17+ ARMv7l

soft_dtw_rust-0.1.1-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (274.3 kB view hashes)

Uploaded CPython 3.12 manylinux: glibc 2.17+ ARM64

soft_dtw_rust-0.1.1-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.whl (276.4 kB view hashes)

Uploaded CPython 3.12 manylinux: glibc 2.5+ i686

soft_dtw_rust-0.1.1-cp312-cp312-macosx_11_0_arm64.whl (234.7 kB view hashes)

Uploaded CPython 3.12 macOS 11.0+ ARM64

soft_dtw_rust-0.1.1-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.1-cp311-none-win_amd64.whl (140.7 kB view hashes)

Uploaded CPython 3.11 Windows x86-64

soft_dtw_rust-0.1.1-cp311-none-win32.whl (134.7 kB view hashes)

Uploaded CPython 3.11 Windows x86

soft_dtw_rust-0.1.1-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.1-cp311-cp311-musllinux_1_2_i686.whl (456.6 kB view hashes)

Uploaded CPython 3.11 musllinux: musl 1.2+ i686

soft_dtw_rust-0.1.1-cp311-cp311-musllinux_1_2_armv7l.whl (534.7 kB view hashes)

Uploaded CPython 3.11 musllinux: musl 1.2+ ARMv7l

soft_dtw_rust-0.1.1-cp311-cp311-musllinux_1_2_aarch64.whl (452.9 kB view hashes)

Uploaded CPython 3.11 musllinux: musl 1.2+ ARM64

soft_dtw_rust-0.1.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (266.8 kB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

soft_dtw_rust-0.1.1-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl (324.5 kB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ s390x

soft_dtw_rust-0.1.1-cp311-cp311-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl (304.5 kB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ ppc64le

soft_dtw_rust-0.1.1-cp311-cp311-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (272.1 kB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ ARMv7l

soft_dtw_rust-0.1.1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (274.6 kB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ ARM64

soft_dtw_rust-0.1.1-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.whl (276.4 kB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.5+ i686

soft_dtw_rust-0.1.1-cp311-cp311-macosx_11_0_arm64.whl (234.5 kB view hashes)

Uploaded CPython 3.11 macOS 11.0+ ARM64

soft_dtw_rust-0.1.1-cp311-cp311-macosx_10_12_x86_64.whl (239.0 kB view hashes)

Uploaded CPython 3.11 macOS 10.12+ x86-64

soft_dtw_rust-0.1.1-cp310-none-win_amd64.whl (140.8 kB view hashes)

Uploaded CPython 3.10 Windows x86-64

soft_dtw_rust-0.1.1-cp310-none-win32.whl (134.7 kB view hashes)

Uploaded CPython 3.10 Windows x86

soft_dtw_rust-0.1.1-cp310-cp310-musllinux_1_2_x86_64.whl (437.8 kB view hashes)

Uploaded CPython 3.10 musllinux: musl 1.2+ x86-64

soft_dtw_rust-0.1.1-cp310-cp310-musllinux_1_2_i686.whl (456.7 kB view hashes)

Uploaded CPython 3.10 musllinux: musl 1.2+ i686

soft_dtw_rust-0.1.1-cp310-cp310-musllinux_1_2_armv7l.whl (534.8 kB view hashes)

Uploaded CPython 3.10 musllinux: musl 1.2+ ARMv7l

soft_dtw_rust-0.1.1-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.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (267.0 kB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

soft_dtw_rust-0.1.1-cp310-cp310-manylinux_2_17_s390x.manylinux2014_s390x.whl (325.2 kB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ s390x

soft_dtw_rust-0.1.1-cp310-cp310-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl (304.7 kB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ ppc64le

soft_dtw_rust-0.1.1-cp310-cp310-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (272.1 kB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ ARMv7l

soft_dtw_rust-0.1.1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (274.8 kB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ ARM64

soft_dtw_rust-0.1.1-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.1-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.1-cp39-none-win_amd64.whl (140.7 kB view hashes)

Uploaded CPython 3.9 Windows x86-64

soft_dtw_rust-0.1.1-cp39-none-win32.whl (134.7 kB view hashes)

Uploaded CPython 3.9 Windows x86

soft_dtw_rust-0.1.1-cp39-cp39-musllinux_1_2_x86_64.whl (437.8 kB view hashes)

Uploaded CPython 3.9 musllinux: musl 1.2+ x86-64

soft_dtw_rust-0.1.1-cp39-cp39-musllinux_1_2_i686.whl (457.0 kB view hashes)

Uploaded CPython 3.9 musllinux: musl 1.2+ i686

soft_dtw_rust-0.1.1-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.1-cp39-cp39-musllinux_1_2_aarch64.whl (453.3 kB view hashes)

Uploaded CPython 3.9 musllinux: musl 1.2+ ARM64

soft_dtw_rust-0.1.1-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.1-cp39-cp39-manylinux_2_17_s390x.manylinux2014_s390x.whl (324.6 kB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ s390x

soft_dtw_rust-0.1.1-cp39-cp39-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl (304.4 kB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ ppc64le

soft_dtw_rust-0.1.1-cp39-cp39-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (272.3 kB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ ARMv7l

soft_dtw_rust-0.1.1-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (274.9 kB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ ARM64

soft_dtw_rust-0.1.1-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.whl (276.2 kB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.5+ i686

soft_dtw_rust-0.1.1-cp39-cp39-macosx_11_0_arm64.whl (234.8 kB view hashes)

Uploaded CPython 3.9 macOS 11.0+ ARM64

soft_dtw_rust-0.1.1-cp38-none-win_amd64.whl (140.5 kB view hashes)

Uploaded CPython 3.8 Windows x86-64

soft_dtw_rust-0.1.1-cp38-none-win32.whl (134.5 kB view hashes)

Uploaded CPython 3.8 Windows x86

soft_dtw_rust-0.1.1-cp38-cp38-musllinux_1_2_x86_64.whl (437.6 kB view hashes)

Uploaded CPython 3.8 musllinux: musl 1.2+ x86-64

soft_dtw_rust-0.1.1-cp38-cp38-musllinux_1_2_i686.whl (456.6 kB view hashes)

Uploaded CPython 3.8 musllinux: musl 1.2+ i686

soft_dtw_rust-0.1.1-cp38-cp38-musllinux_1_2_armv7l.whl (534.6 kB view hashes)

Uploaded CPython 3.8 musllinux: musl 1.2+ ARMv7l

soft_dtw_rust-0.1.1-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.1-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.1-cp38-cp38-manylinux_2_17_s390x.manylinux2014_s390x.whl (324.4 kB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ s390x

soft_dtw_rust-0.1.1-cp38-cp38-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl (304.5 kB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ ppc64le

soft_dtw_rust-0.1.1-cp38-cp38-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (271.9 kB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ ARMv7l

soft_dtw_rust-0.1.1-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (274.6 kB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ ARM64

soft_dtw_rust-0.1.1-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.whl (276.0 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