Skip to content

detecta 0.1.0: classical CUSUM options, reliable change endings, marimo notebooks

Latest

Choose a tag to compare

@demotu demotu released this 21 Oct 02:18
· 9 commits to master since this release

Highlights

  • detect_cusum gets a reference parameter, to choose the level that each sample is compared with, s[t] = x[t] − reference[t−1]:

    • 'previous' (default): the previous sample, the same detection as in 0.0.5
    • 'residual': exponentially weighted mean, set with the new alpha parameter (Gustafsson, 2000)
    • 'run_mean': mean of the data so far, as in the Page-Hinkley test
    • 'mean': mean of a baseline of n_baseline samples (classical CUSUM, Page 1954)
    • a number: a known, fixed reference level

    The estimated references restart after each detected change. With a reference level, small sustained changes can be detected; with 'previous' they could not.

  • Reliable ending of changes (ending=True): each change now gets exactly one ending, found by running the algorithm backwards over that change's own stretch of data. The old reverse run and its pairing heuristics could drop
    detected changes or pair them with the wrong ending.

  • Example notebooks are now marimo notebooks, with interactive examples. Run them in the browser from the links in the README.

Changes that affect results

  • detect_cusum(..., ending=True): taf and amp can differ from 0.0.5, and detected changes are no longer dropped. amp is now the difference between the mean of the data after and before the change, instead of the difference
    between two single samples.
  • detect_cusum with the default reference='previous' and ending=False returns the same ta and tai as 0.0.5.

Fixes

  • detect_peaks: replaced np.in1d, deprecated in NumPy 2, with np.isin. Data with NaN's triggered this code path.
  • detect_seq: the sequence lengths used by max_alert were one sample short.
  • detect_cusum: plotting into axes you pass in (ax) now works (#3, by @piiq). This fix is released here for the first time.

Packaging

  • pyproject.toml replaces setup.py. numpy is now a declared dependency, and the license is listed as MIT.
  • Requires Python ≥ 3.9. Tested on 3.9, 3.12 and 3.14, with NumPy 1.x and 2.x.
  • pip install "detecta[plot]" also installs matplotlib for the plots.
  • New test suite, and continuous integration that publishes to PyPI from GitHub releases.

Full changelog: v0.0.5...v0.1.0