tsseg.algorithms.window package
Window — sliding-window discrepancy change point detection.
Description
Window-based detection slides two adjacent windows along the signal and computes a discrepancy measure \(d(\cdot,\cdot)\) derived from the cost function:
When both windows fall inside the same segment their statistical properties are similar and the discrepancy is low. When they straddle a change point the discrepancy spikes. A sequential peak search on the discrepancy curve produces the final change points.
Complexity is \(O(n\,w)\) where w is the window width — making Window one
of the fastest methods. The jump parameter further speeds up prediction at
the expense of positional precision.
Parameters
Name |
Type |
Default |
Description |
|---|---|---|---|
|
int |
|
Width of each sliding window (in samples). |
|
int / None |
|
Number of change points. |
|
float / None |
|
Penalty threshold. |
|
float / None |
|
Reconstruction-error tolerance. |
|
str |
|
Ruptures cost model. |
|
int |
|
Minimum segment length. |
|
int |
|
Sub-sampling factor for candidates. |
|
dict / None |
|
Extra keyword arguments for the cost factory. |
|
int |
|
Time axis. |
Usage
from tsseg.algorithms import WindowDetector
detector = WindowDetector(width=50, model="l2", n_cps=3)
labels = detector.fit_predict(X)
# Penalty-based stopping
import numpy as np
detector = WindowDetector(width=50, model="l2", pen=np.log(n) * d * sigma**2)
labels = detector.fit_predict(X)
Implementation: Vendored from ruptures v1.1.8. BSD 2-Clause.
Reference: Basseville & Nikiforov (1993), Detection of Abrupt Changes, Prentice Hall.