Changepoint detection with Pruned Exact Linear Time.
Usage
Python
from pelt import predict
predict(signal, penalty=20, segment_cost_function="l1", jump=10, minimum_segment_length=2)
Rust
use std::num::NonZero;
use pelt::{Pelt, SegmentCostFunction};
// Setup the structure for calculating changepoints
let pelt = Pelt::new()
.with_jump(NonZero::new(5).expect("Invalid number"))
.with_minimum_segment_length(NonZero::new(2).expect("Invalid number"))
.with_segment_cost_function(SegmentCostFunction::L1);
// Do the calculation on a data set
let penalty = 10.0;
let result = pelt.predict(&signal[..], penalty)?;
Run locally
# Install maturin inside a Python environment
python3 -m venv .env
source .env/bin/activate
pip install maturin numpy
# Create a Python package from the Rust code
maturin develop
# Open an interpreter
python
>>> from pelt import predict
>>> import numpy as np
>>> signal = np.array([np.sin(np.arange(0, 1000, 10))]).transpose()
>>> predict(signal, penalty=20)
Benchmarks
[!WARNING] Like all benchmarks, take these with a grain of salt.
Python
Comparison with ruptures:
| Cost Function | Data Points | Data Dimension | Mean pelt |
Mean ruptures |
Times Faster |
|---|---|---|---|---|---|
| L2 | 100 | 1D | 2.042 μs | 3.110 ms | 1523.1x |
| L2 | 100 | 2D | 2.420 μs | 3.148 ms | 1300.9x |
| L2 | 1000 | 1D | 106.783 μs | 190.108 ms | 1780.3x |
| L2 | 1000 | 2D | 55.815 μs | 104.357 ms | 1869.7x |
| L2 | 10000 | 1D | 20.407 ms | 12.859 s | 630.2x |
| L2 | 10000 | 2D | 2.317 ms | 1.797 s | 775.6x |
| L1 | 100 | 1D | 11.245 μs | 5.041 ms | 448.3x |
| L1 | 100 | 2D | 21.587 μs | 5.350 ms | 247.8x |
| L1 | 1000 | 1D | 321.619 μs | 187.656 ms | 583.5x |
| L1 | 1000 | 2D | 2.186 ms | 628.126 ms | 287.3x |
| L1 | 10000 | 1D | 13.215 ms | 15.615 s | 1181.6x |
| L1 | 10000 | 2D | 84.453 ms | 30.508 s | 361.2x |
Command
maturin develop
python benches/bench_compare.py
Profile
Command
cargo build --example simple --profile profiling \
&& samply record target/profiling/examples/simple tests/signals-large.csv
Credits
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pelt-0.3.2.tar.gz.
File metadata
- Download URL: pelt-0.3.2.tar.gz
- Upload date:
- Size: 92.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
maturin/1.14.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7615b827c4879817dbfbb0fc9f216a3eb80900ba154680f68b1e2897d621ecaf
|
|
| MD5 |
d5eb60c59a393f0b4a22ae997144f624
|
|
| BLAKE2b-256 |
62b6343e0b775dd951bb9b6bc1c8da5623200d2bca2d7882bf8d9fc1c12a68b8
|
File details
Details for the file pelt-0.3.2-cp314-cp314-manylinux_2_34_x86_64.whl.
File metadata
- Download URL: pelt-0.3.2-cp314-cp314-manylinux_2_34_x86_64.whl
- Upload date:
- Size: 275.6 kB
- Tags: CPython 3.14, manylinux: glibc 2.34+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
maturin/1.14.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7bca40d7a8dfaa3802a87759707d303eeff2a7c0ada64de21521c5e7abe2d301
|
|
| MD5 |
273f0428e4f3063fa4be9b1cfd77b649
|
|
| BLAKE2b-256 |
b89ceb9e6c48703edaaee108f2792b67e0d96479e147554d6f4a8d4d6ad00eab
|
File details
Details for the file pelt-0.3.2-cp314-cp314-macosx_11_0_arm64.whl.
File metadata
- Download URL: pelt-0.3.2-cp314-cp314-macosx_11_0_arm64.whl
- Upload date:
- Size: 237.5 kB
- Tags: CPython 3.14, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
maturin/1.14.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e156d28140e4862b9c23e06c9aa9d336377c6182261e6679b2be6e3a41ffa2b2
|
|
| MD5 |
c59bd907384b50c141f60ee194e2db63
|
|
| BLAKE2b-256 |
01cd518f293329f9604643aa8f576a5b03c9f356f3f4fcd411121acffa18e87d
|
File details
Details for the file pelt-0.3.2-cp312-cp312-win_amd64.whl.
File metadata
- Download URL: pelt-0.3.2-cp312-cp312-win_amd64.whl
- Upload date:
- Size: 173.3 kB
- Tags: CPython 3.12, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
maturin/1.14.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9a2fae5cfa6cde0ea3c5c43d1742bc234862b0aeb2e4654e65fd07e322c1277a
|
|
| MD5 |
c993b36e7aa685d6463e23cba5b2069f
|
|
| BLAKE2b-256 |
b1e4ece3d53b0196377c2770911e5024454916efaa58cb78bc8357c87518ad75
|
File details
Details for the file pelt-0.3.2-cp312-cp312-manylinux_2_34_x86_64.whl.
File metadata
- Download URL: pelt-0.3.2-cp312-cp312-manylinux_2_34_x86_64.whl
- Upload date:
- Size: 278.9 kB
- Tags: CPython 3.12, manylinux: glibc 2.34+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
maturin/1.14.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
579bca400f4f7036a8881e774faf9887ca85fcf0c45fd33f0dec0899a02f23ca
|
|
| MD5 |
3576d62aaea06942cbe905dfa94c6e7c
|
|
| BLAKE2b-256 |
30a5582c288787f22537d31f35e5eae3425d6f61951063cf19e448d9d09fb73a
|