tsseg.algorithms.amoc package

AMOC (At Most One Change) — single change point detection.

Description

AMOC searches for the single breakpoint that minimises the total sum of squared errors (SSE) on either side of the split. It is the foundational building block used internally by multi-change detectors such as Binary Segmentation and PELT, which repeatedly apply the single-change solver on sub-segments of the signal.

Type: change point detection
Supervision: fully unsupervised
Scope: univariate and multivariate
Complexity: \(O(n\,d)\) time, \(O(1)\) extra memory

Parameters

Name

Type

Default

Description

min_size

int

5

Minimum number of samples required on each side of the breakpoint.

axis

int

0

Axis representing time in the input array.

Usage

from tsseg.algorithms import AmocDetector

detector = AmocDetector(min_size=10)
labels = detector.fit_predict(X)

Implementation: Clean-room reimplementation of the classical SSE-based single change point criterion. Inspired by the R changepoint package (GPL >= 2), no R code reused. Origin: new code.

Reference: Killick, Fearnhead & Eckley (2012), JASA.

Submodules

tsseg.algorithms.amoc.detector module

AMOC detector integrated with aeon’s BaseSegmenter API.

class tsseg.algorithms.amoc.detector.AmocDetector(*, min_size=5, axis=0)[source]

Bases: BaseSegmenter

AMOC (At Most One Change) detector.

The AMOC objective searches for the breakpoint that minimises the sum of squared errors on either side of the split. It is a foundational building block for many multi-change detectors (e.g. Binary Segmentation and PELT), which repeatedly apply the single-change solver on sub-segments of the signal.

Parameters:
  • min_size (int) – Minimum number of samples required on each side of the breakpoint.

  • axis (int) – Axis representing time in the input array.

References

Examples

>>> import numpy as np
>>> from tsseg.algorithms.amoc.detector import AmocDetector
>>> rng = np.random.default_rng(7)
>>> x = np.concatenate([
...     rng.normal(0.0, 0.2, size=200),
...     rng.normal(1.0, 0.2, size=200),
... ])
>>> detector = AmocDetector(min_size=20)
>>> detector.fit(x)
AmocDetector(...)
>>> detector.predict(x)
array([...])
get_fitted_params()[source]
set_fit_request(*, axis: bool | None | str = '$UNCHANGED$') AmocDetector

Configure whether metadata should be requested to be passed to the fit method.

Note that this method is only relevant when this estimator is used as a sub-estimator within a meta-estimator and metadata routing is enabled with enable_metadata_routing=True (see sklearn.set_config()). Please check the User Guide on how the routing mechanism works.

The options for each parameter are:

  • True: metadata is requested, and passed to fit if provided. The request is ignored if metadata is not provided.

  • False: metadata is not requested and the meta-estimator will not pass it to fit.

  • None: metadata is not requested, and the meta-estimator will raise an error if the user provides it.

  • str: metadata should be passed to the meta-estimator with this given alias instead of the original name.

The default (sklearn.utils.metadata_routing.UNCHANGED) retains the existing request. This allows you to change the request for some parameters and not others.

Added in version 1.3.

Parameters:

axis (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for axis parameter in fit.

Returns:

self – The updated object.

Return type:

object

set_predict_request(*, axis: bool | None | str = '$UNCHANGED$') AmocDetector

Configure whether metadata should be requested to be passed to the predict method.

Note that this method is only relevant when this estimator is used as a sub-estimator within a meta-estimator and metadata routing is enabled with enable_metadata_routing=True (see sklearn.set_config()). Please check the User Guide on how the routing mechanism works.

The options for each parameter are:

  • True: metadata is requested, and passed to predict if provided. The request is ignored if metadata is not provided.

  • False: metadata is not requested and the meta-estimator will not pass it to predict.

  • None: metadata is not requested, and the meta-estimator will raise an error if the user provides it.

  • str: metadata should be passed to the meta-estimator with this given alias instead of the original name.

The default (sklearn.utils.metadata_routing.UNCHANGED) retains the existing request. This allows you to change the request for some parameters and not others.

Added in version 1.3.

Parameters:

axis (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for axis parameter in predict.

Returns:

self – The updated object.

Return type:

object

Module contents

Aeon-compatible AMOC detector.

class tsseg.algorithms.amoc.AmocDetector(*, min_size=5, axis=0)[source]

Bases: BaseSegmenter

AMOC (At Most One Change) detector.

The AMOC objective searches for the breakpoint that minimises the sum of squared errors on either side of the split. It is a foundational building block for many multi-change detectors (e.g. Binary Segmentation and PELT), which repeatedly apply the single-change solver on sub-segments of the signal.

Parameters:
  • min_size (int) – Minimum number of samples required on each side of the breakpoint.

  • axis (int) – Axis representing time in the input array.

References

Examples

>>> import numpy as np
>>> from tsseg.algorithms.amoc.detector import AmocDetector
>>> rng = np.random.default_rng(7)
>>> x = np.concatenate([
...     rng.normal(0.0, 0.2, size=200),
...     rng.normal(1.0, 0.2, size=200),
... ])
>>> detector = AmocDetector(min_size=20)
>>> detector.fit(x)
AmocDetector(...)
>>> detector.predict(x)
array([...])
get_fitted_params()[source]
set_fit_request(*, axis: bool | None | str = '$UNCHANGED$') AmocDetector

Configure whether metadata should be requested to be passed to the fit method.

Note that this method is only relevant when this estimator is used as a sub-estimator within a meta-estimator and metadata routing is enabled with enable_metadata_routing=True (see sklearn.set_config()). Please check the User Guide on how the routing mechanism works.

The options for each parameter are:

  • True: metadata is requested, and passed to fit if provided. The request is ignored if metadata is not provided.

  • False: metadata is not requested and the meta-estimator will not pass it to fit.

  • None: metadata is not requested, and the meta-estimator will raise an error if the user provides it.

  • str: metadata should be passed to the meta-estimator with this given alias instead of the original name.

The default (sklearn.utils.metadata_routing.UNCHANGED) retains the existing request. This allows you to change the request for some parameters and not others.

Added in version 1.3.

Parameters:

axis (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for axis parameter in fit.

Returns:

self – The updated object.

Return type:

object

set_predict_request(*, axis: bool | None | str = '$UNCHANGED$') AmocDetector

Configure whether metadata should be requested to be passed to the predict method.

Note that this method is only relevant when this estimator is used as a sub-estimator within a meta-estimator and metadata routing is enabled with enable_metadata_routing=True (see sklearn.set_config()). Please check the User Guide on how the routing mechanism works.

The options for each parameter are:

  • True: metadata is requested, and passed to predict if provided. The request is ignored if metadata is not provided.

  • False: metadata is not requested and the meta-estimator will not pass it to predict.

  • None: metadata is not requested, and the meta-estimator will raise an error if the user provides it.

  • str: metadata should be passed to the meta-estimator with this given alias instead of the original name.

The default (sklearn.utils.metadata_routing.UNCHANGED) retains the existing request. This allows you to change the request for some parameters and not others.

Added in version 1.3.

Parameters:

axis (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for axis parameter in predict.

Returns:

self – The updated object.

Return type:

object