Skip to main content

ruptures-rs

Find the moments a time series changed behaviour.

PyPI Python CI License

A 2,000-point noisy signal with six change points. Shading marks the true regimes; the bold line is the piecewise-constant model ruptures-rs fitted, whose steps land on the regime boundaries to within twenty samples out of two thousand.

What this is for

You have a sequence of measurements, and partway through, something changed — and stayed changed. Change point detection finds those moments: the boundaries between stretches where the data behaves one way and stretches where it behaves another.

That is a different question from anomaly detection. An anomaly is one odd reading. A change point is where a new normal begins. If your latency rose after a deploy and stayed up, no single request looks wrong, but there is a moment worth finding.

It comes up wherever a process has regimes:

  • Operations — when did the error rate shift, and does it line up with the release?
  • Industrial sensors — split a run into phases, or catch where a machine's vibration signature changed.
  • Finance — divide a series into volatility regimes instead of assuming one.
  • Genomics — copy number segmentation, which is where much of this literature comes from.
  • Wearables — cut an accelerometer trace into activities.

You supply the signal and either the number of changes you expect or a penalty for adding one. You get back the breakpoints.

Quick start

pip install ruptures-rs
import ruptures_rs as rpt

# A synthetic signal with six changes, so the example runs anywhere.
signal, true_bkps = rpt.pw_constant(2_000, 1, 6, noise_std=3, seed=11)

# "I expect six changes. Where are they?"
bkps = rpt.Dynp(model="l2", min_size=20, jump=5).fit(signal).predict(6)
#  -> [275, 550, 840, 1120, 1415, 1710, 2000]      in 1.6 ms

# "I don't know how many. Charge me 500 for each one you add."
bkps = rpt.Pelt(model="l2", min_size=20).fit(signal).predict(pen=500)

rpt.display(signal, true_bkps, bkps)   # needs matplotlib

A breakpoint is the end of a segment, and the last one is always the length of the signal — the same convention ruptures uses.

Choose a detector by what you know going in. Dynp when you know the number of changes and want the exact optimum. Pelt when you do not, and would rather set a penalty. Binseg and BottomUp for a quick approximate answer. Window for a fast scan of a long signal.

Choose a cost by the kind of change you are looking for. l2 for shifts in the mean, normal for shifts in variance or correlation, rbf for changes in distribution that are not just the mean, linear and ar for a change in a relationship or a temporal model.

A drop-in replacement for ruptures

This reimplements ruptures, the standard Python library for this problem, with the same API.

- import ruptures as rpt
+ import ruptures_rs as rpt

That is the whole migration. Same classes, same arguments, same breakpoints — verified by 1,392 tests that run both libraries on the same input and demand identical output, not merely similar output.

It also installs where the reference currently cannot. One abi3 wheel per platform covers Python 3.10 through 3.14, including musl, so pip install never has to go looking for a C compiler.

Fast enough to change what you attempt

Horizontal bar chart of measured speedups against ruptures, log scale, ranging from 23x for BottomUp to 4,863x for Dynp on 2,000 samples.

ruptures evaluates its cost function once per cell of a dynamic-programming table, and every call is an O(segment length) NumPy reduction. Nearly all of those costs are a difference of prefix sums in disguise, which makes them O(1) — so the gain is structural, not just the constant factor from leaving Python.

The practical effect is that exact segmentation stops being something you budget for. A 50,000-point signal takes 0.06 s here, and is not a workload the reference can run at all.

Full benchmark tables →

Choosing a penalty without guessing

The CROPS penalty path: number of change points against penalty, on log axes, as a staircase of 86 optimal segmentations. The widest step is highlighted, showing four changes holding across a 25x span of penalties.

Penalised detection asks you for a penalty, and nobody knows theirs in advance. Crops returns every segmentation that is optimal somewhere in a penalty range, with the exact interval each one owns:

for regime in rpt.Crops(model="l2", min_size=10).fit_predict(signal, 1, 20_000):
    print(f"{regime.n_bkps:2d} changes for penalty in "
          f"[{regime.pen_min:,.0f}, {regime.pen_max:,.0f}]")

The answer that survives the widest span of penalties is the defensible one, because it is the least sensitive to the parameter you could not justify picking. ruptures has no equivalent, and it is only practical here because PELT became cheap enough to run dozens of times. examples/penalty_path.py works through it.

What's included

Everything in ruptures 1.1.9, plus Crops:

Detectors Dynp, Pelt, Binseg, BottomUp, Window, KernelCPD, Crops
Costs l1, l2, normal, rbf, cosine, rank, mahalanobis, clinear, linear, ar
Datasets pw_constant, pw_linear, pw_normal, pw_wavy
Metrics precision_recall, hausdorff, randindex, meantime, hamming
Also display, cost_factory, BaseCost, BaseEstimator, Bnode, exceptions

Your own custom_cost still works. It runs on a pure-Python implementation, because a Python callable inside the inner loop cannot be made faster by crossing an FFI boundary to reach it — same answers, original speed. estimator.accelerated reports which path you are on.

Going deeper

For code you cannot edit

When a dependency deep in the stack imports ruptures by name:

import ruptures_rs
ruptures_rs.install()   # before anything imports `ruptures`

import ruptures as rpt  # this is now ruptures_rs

It refuses rather than half-patching the module graph if the real ruptures has already been imported.

Development

pip install maturin pytest numpy scipy ruptures
maturin develop --release
pytest tests/ -q
cargo test

Licence and credit

BSD-2-Clause, the same licence as ruptures.

This is a reimplementation of ruptures by Charles Truong, Laurent Oudre and Nicolas Vayatis, whose API, algorithms and semantics it deliberately reproduces. The pure-Python fallback in _fallback.py is a direct port of their code. If you use this in research, cite their paper:

C. Truong, L. Oudre, N. Vayatis. Selective review of offline change point detection methods. Signal Processing, 167:107299, 2020.

Metadata

Release files for ruptures-rs 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ruptures-rs 0.1.1
File Size Uploaded
ruptures_rs-0.1.1.tar.gz 89.8 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for ruptures-rs 0.1.1
File
ruptures_rs-0.1.1-cp310-abi3-win_amd64.whl CPython 3.10 abi3 Windows x86-64 Details
ruptures_rs-0.1.1-cp310-abi3-musllinux_1_2_x86_64.whl CPython 3.10 abi3 Linux musl 1.2+ x86-64 Details
ruptures_rs-0.1.1-cp310-abi3-musllinux_1_2_aarch64.whl CPython 3.10 abi3 Linux musl 1.2+ ARM64 Details
ruptures_rs-0.1.1-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.10 abi3 Linux glibc 2.17+ x86-64 Details
ruptures_rs-0.1.1-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl CPython 3.10 abi3 Linux glibc 2.17+ ARM64 Details
ruptures_rs-0.1.1-cp310-abi3-macosx_11_0_arm64.whl CPython 3.10 abi3 macOS 11.0+ ARM64 Details
ruptures_rs-0.1.1-cp310-abi3-macosx_10_12_x86_64.whl CPython 3.10 abi3 macOS 10.12+ x86-64 Details

Total release size: 3.4 MB

Release files / ruptures_rs-0.1.1.tar.gz

Download URL ruptures_rs-0.1.1.tar.gz
Size 89.8 kB
Tags Source
SHA-256 checksum
How to use checksums
3ec53c3a13cedbb5cf771fe2937577e8442cd895278b01d5f39dfbfc7b8bc572
BLAKE2b-256 checksum
How to use checksums
d261691332db2b3b42244e1f38d4c34b1c27e92f22c1b4f7385c2aafc2456ff7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 7, 2026.

Transparency log

Release files / ruptures_rs-0.1.1-cp310-abi3-win_amd64.whl

Download URL ruptures_rs-0.1.1-cp310-abi3-win_amd64.whl
Size 321.8 kB
Tags CPython 3.10 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
ec4a7caa7be651da8e1c58bbd7ee01490ceb1b8d17e36ee3f580e572ca098da7
BLAKE2b-256 checksum
How to use checksums
259eff2b918f002d2324139dcac2465ea3b9643217e88e5a9d5bc1a228564cd7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 7, 2026.

Transparency log

Release files / ruptures_rs-0.1.1-cp310-abi3-musllinux_1_2_x86_64.whl

Download URL ruptures_rs-0.1.1-cp310-abi3-musllinux_1_2_x86_64.whl
Size 656.3 kB
Tags CPython 3.10 Linux musl 1.2+ x86-64 abi3
SHA-256 checksum
How to use checksums
33999c70f25f0ce0bc6700d56070d85005f0fec47d383e21d4f853e46df1c8b7
BLAKE2b-256 checksum
How to use checksums
58d96929085ef286057767a34f038934b7f9d0d84ccd03c6c892899affa35414
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 7, 2026.

Transparency log

Release files / ruptures_rs-0.1.1-cp310-abi3-musllinux_1_2_aarch64.whl

Download URL ruptures_rs-0.1.1-cp310-abi3-musllinux_1_2_aarch64.whl
Size 611.0 kB
Tags CPython 3.10 Linux musl 1.2+ ARM64 abi3
SHA-256 checksum
How to use checksums
a2c8d65ab8c4c70c0189b4a02983841eeefca2242bc935be3915e5e2ffd5345c
BLAKE2b-256 checksum
How to use checksums
bed5abc1158ba99dedb9d87f365514215915109cd4aa9fd8b2ecf01ef22fa075
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 7, 2026.

Transparency log

Release files / ruptures_rs-0.1.1-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL ruptures_rs-0.1.1-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 444.0 kB
Tags CPython 3.10 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
7c1ab5c8676bda9a9afebfbd33983b1ca9832bd94afbb04a8556c3446f38589a
BLAKE2b-256 checksum
How to use checksums
25f37393fb0e946e6964960986dd1f77b5b277a987132fed0e035519b7c716c4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 7, 2026.

Transparency log

Release files / ruptures_rs-0.1.1-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Download URL ruptures_rs-0.1.1-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Size 432.4 kB
Tags CPython 3.10 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
3ed307a660d6ddf44a39c32355fc429382e176f6bb99a345020af3da4ee59db2
BLAKE2b-256 checksum
How to use checksums
d3982ed149cb71e9ebca9e9f0d13555a446c8b0f7c88673d81e7d5db4e33bfd9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 7, 2026.

Transparency log

Release files / ruptures_rs-0.1.1-cp310-abi3-macosx_11_0_arm64.whl

Download URL ruptures_rs-0.1.1-cp310-abi3-macosx_11_0_arm64.whl
Size 396.9 kB
Tags CPython 3.10 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
8cda6b3104726dbe2e38b86a6866a91fed7cd8f41930345b54fadfcd3c0cdf4e
BLAKE2b-256 checksum
How to use checksums
dbbf0e9b4ceee4fb12fa1ccc512bddb84eca7430443445f56b1f08fce41f85bf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 7, 2026.

Transparency log

Release files / ruptures_rs-0.1.1-cp310-abi3-macosx_10_12_x86_64.whl

Download URL ruptures_rs-0.1.1-cp310-abi3-macosx_10_12_x86_64.whl
Size 416.0 kB
Tags CPython 3.10 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
ea213a193cf120c65d5c7a87dcf4a04617f80a8f0ccccc77783efb3002fb669e
BLAKE2b-256 checksum
How to use checksums
bba3f02f933de617e89669ff1fa8b168c463c53707b949fca0b79dfbb12e72ed
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 7, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.1.1 This release

8 release files

0.1.0

8 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page