Quick Reference · offline change-point detection · ruptures 1.1

ruptures cheat sheet

Find the moments a signal's behaviour shifts — in mean, variance, slope, or whole distribution. Every detector is built from three parts: a cost function (what kind of change), a search method (how to find it), and a constraint (how many). Fit on a NumPy array, predict a list of breakpoints. Learn the recipe once and mix & match.

signal / io search method cost model constraint display & metrics advanced / tuning gotcha most common

Distilled & cross-checked against: centre-borelli.github.io/ruptures-docs · github.com/deepcharles/ruptures · Truong, Oudre & Vayatis, "Selective review of offline change point detection methods" (Signal Processing, 2020) · pypi.org/project/ruptures

The pipeline — from a signal to a list of breakpoints
signal NumPy array (n_samples,) or (n, n_dim) rpt.Pelt( model="rbf" ) search + cost model + min_size · jump .fit(signal) precompute costs over segments .predict( pen=10 ) constraint: n_bkps / pen / epsilon bkps segment-end idx [120, 250, …, n] last == len(signal) rpt.display(signal, bkps) precision_recall · hausdorff INPUT BUILD · FIT DETECT OUTPUT
every detector = cost functionwhat change× search methodhow to find it× constrainthow many  ·  pick one from each column — the modular framework of Truong, Oudre & Vayatis (2020)
01Install & Importonce per env
02The Signalinput & toy data
03Core Recipethe whole job
04Search Methodshow to find them
05Cost Modelswhat kind of change
06Constraintshow many changes?
07Tuning Knobsspeed vs precision
08Read the Outputwhat bkps means
09Displaysee it
10Evaluation Metricsscore vs truth
11Custom Costyour own change
12Choosing a Penaltyunknown count
Which one?quick decision

How ruptures thinks

One definition and three ideas carry the library — a change point, the cost×search×constraint recipe, how the search methods explore, and what each cost is tuned to notice.

What is a change point?

An index where the signal's statistics shift. Breakpoints split the series into homogeneous regimes — exactly what rpt.display shades.

regime 1 regime 2 regime 3 4 | = breakpoint

cost × search × constraint

The modular framework: any detector is one choice from each column. Swap parts freely to match the change you expect and the budget you have.

COST SEARCH CONSTRAINT l2 · mean normal · var rbf · dist ar · linear Pelt Dynp Binseg Window n_bkps pen epsilon rpt.Pelt(model="rbf").predict(pen=10)

How the search explores

Binary segmentation splits greedily & recursively; a sliding window scans a discrepancy score. Exact methods (Dynp/Pelt) instead optimise globally.

Binseg — recursive split 1st 2nd 2nd Window — sliding discrepancy left right score peak = change

What each cost notices

The cost model decides which kind of shift counts. Same search, different lens — pick the one that matches your change.

l2 — mean normal — variance linear — slope rbf — distribution

Worth memorizing

cost × search × constraintwhat change · how to find · how many
bkps = end indiceslast one is always len(signal)
known K → n_bkpsunknown K → pen or epsilon
exact vs approxDynp/Pelt exact · Binseg/BottomUp/Window greedy
Peltexact and near-linear time — the workhorse
KernelCPDC-fast; jump fixed at 1; kernels linear/rbf/cosine
model="l2" / "rbf"mean shift · full distribution change
higher pen⇒ fewer breakpoints (the over-segmentation dial)
jump ↑ / min_sizefaster coarser grid · floor on segment length
offlinewhole signal at once — not streaming/online