tsseg.algorithms.binseg package
Binary Segmentation (BinSeg) — fast sequential change point detection.
Description
Binary segmentation is a greedy, top-down procedure: it first detects a single change point in the full signal, then splits the series at that point and repeats the operation on each sub-signal until a stopping criterion is met.
The benefits include low complexity — \(O(C\,n\log n)\) where n is the number of samples and C the cost of evaluating the cost function on one sub-signal — and the ability to work whether the number of regimes is known beforehand or not.
Parameters
Name |
Type |
Default |
Description |
|---|---|---|---|
|
int / None |
|
Number of change points. When |
|
str |
|
Ruptures cost model ( |
|
int |
|
Minimum segment length. |
|
int |
|
Sub-sampling factor for candidate breakpoints. |
|
float / None |
|
Penalty value (BIC-style). Mutually exclusive with |
|
float / None |
|
Reconstruction-error tolerance. Mutually exclusive with |
|
BaseCost / None |
|
Pre-instantiated ruptures cost object. |
|
dict / None |
|
Additional keyword arguments forwarded to the cost factory. |
|
int |
|
Axis representing time. |
Usage
from tsseg.algorithms import BinSegDetector
detector = BinSegDetector(model="l2", n_cps=3)
labels = detector.fit_predict(X)
# Unknown number of change points — use a penalty
detector = BinSegDetector(model="l2", penalty=10)
labels = detector.fit_predict(X)
Implementation: Vendored from ruptures v1.1.8. BSD 2-Clause.
Reference: Bai (1997), Econometric Theory; Fryzlewicz (2014), The Annals of Statistics.