Changepoint detection with Pruned Exact Linear Time
Project description
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 --features python
# 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 | 0.004ms | 3.113ms | 753.1x |
| L2 | 100 | 2D | 0.005ms | 3.251ms | 608.5x |
| L2 | 1000 | 1D | 0.419ms | 188.546ms | 449.8x |
| L2 | 1000 | 2D | 0.572ms | 94.201ms | 164.7x |
| L2 | 10000 | 1D | 95.851ms | 12.103s | 126.3x |
| L2 | 10000 | 2D | 19.871ms | 1.778s | 89.5x |
| L1 | 100 | 1D | 0.010ms | 5.101ms | 508.8x |
| L1 | 100 | 2D | 0.025ms | 5.323ms | 213.0x |
| L1 | 1000 | 1D | 0.641ms | 180.250ms | 281.3x |
| L1 | 1000 | 2D | 3.595ms | 638.049ms | 177.5x |
| L1 | 10000 | 1D | 43.444ms | 15.710s | 361.6x |
| L1 | 10000 | 2D | 364.553ms | 30.572s | 83.9x |
Command
maturin develop --features python --release
python benches/bench_compare.py
Profile
Command
cargo build --example simple --profile profiling \
&& samply record target/profiling/examples/simple tests/signals-large.csv
Credits
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
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.0.tar.gz.
File metadata
- Download URL: pelt-0.3.0.tar.gz
- Upload date:
- Size: 95.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.10.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
70793684e9c13c08992dd557ac289c7954ffb4ce28bc743bf772020b5a6379d0
|
|
| MD5 |
4122161ac10a1547d42e491e9d961e70
|
|
| BLAKE2b-256 |
b52ac00ba9e9329bfcef3f6620bc8c2447ae338f3073d85a64134389e6af328f
|
File details
Details for the file pelt-0.3.0-cp314-cp314-macosx_11_0_arm64.whl.
File metadata
- Download URL: pelt-0.3.0-cp314-cp314-macosx_11_0_arm64.whl
- Upload date:
- Size: 232.1 kB
- Tags: CPython 3.14, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.10.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0b4455beaa8defc37175456a4333d695366b1e6c03fb0e7a5e6736a3358881d2
|
|
| MD5 |
d2300752dc44a7fae896691979963744
|
|
| BLAKE2b-256 |
575c2cc91af6ca6b88e27d9d27654b4442361270bc649bc7bad3c28034a343b7
|
File details
Details for the file pelt-0.3.0-cp39-cp39-win_amd64.whl.
File metadata
- Download URL: pelt-0.3.0-cp39-cp39-win_amd64.whl
- Upload date:
- Size: 166.6 kB
- Tags: CPython 3.9, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.10.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fec6197675086f63d5bc3909e1157c23e4c3db2643d993351b50e785668f6dbb
|
|
| MD5 |
3ba2351fe7cea310295866b58791e8c9
|
|
| BLAKE2b-256 |
fa1dcef230b5dffdb6a881fa1597af2b2358f64f1804713d19814f93445a8c01
|
File details
Details for the file pelt-0.3.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: pelt-0.3.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 273.6 kB
- Tags: CPython 3.8, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: maturin/1.10.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e47f960d29ab527264cf32deb214ba39fb16e1986c0e083c7112c122fda8a111
|
|
| MD5 |
c0969a271982e411d4ce7f857c898126
|
|
| BLAKE2b-256 |
cfba07e37234319f06e7b0e9c4671f8925361b13216c7c9b86f36e8c7a122d21
|