AutoPlait#

AutoPlait – parameter-free mining of co-evolving time sequences.

Description#

AutoPlait describes a (multivariate) time series as segments, each generated by one of a few regimes. A regime is a hidden Markov model with diagonal Gaussian emissions; segments of the same regime share it. The number of regimes, the number of hidden states of each model and the cut points are chosen by minimising the total description length (MDL) of the models and of the data, without any user parameter.

The search is top-down. Starting from a single regime that covers the whole series, AutoPlait tries to split each regime in two:

  1. Seeds – pairs of windows of length \(\lceil n/10 \rceil\) taken uniformly in the regime each initialise an HMM; the pair whose split is the shortest to describe is kept.

  2. CutPointSearch – a Viterbi pass over the two HMMs, with a switching probability per regime, assigns each part of the regime to one of them; segments that the other model describes almost as well are moved to it.

  3. RegimeSplit – model estimation (Baum-Welch, number of states chosen by MDL) and cut point search alternate until the description length stops decreasing.

The split is kept when it shortens the description of the regime by more than 3 %; the two new regimes are then split in turn.

Type: state detection
Supervision: unsupervised
Scope: univariate and multivariate
Complexity: \(O(n)\) per cut point search (for a bounded number of states and of seeds)

Parameters#

Name

Type

Default

Description

n_cps

int / None

None

Deprecated and ignored. AutoPlait chooses the number of segments itself and has no guided mode, so this value has never changed the output. Passing it emits a FutureWarning at fit; it will be removed in a future release.

axis

int

0

Time axis (rows with 0, columns with 1).

Usage#

from tsseg.algorithms import AutoPlaitDetector

detector = AutoPlaitDetector()
labels = detector.fit_predict(X)

labels holds, for each time point, the number of the AutoPlait regime its segment belongs to: segments of the same regime share a label.

Note

AutoPlait needs numba (pip install "tsseg[accelerators]").

The C code floors the log-density of an observation, summed over its channels, at \(\log 10^{-6}\), and the translation keeps this floor. With many channels, the observations reach it under every model and the models can no longer be told apart. About 20 % of the time points of a HAS series (9 channels) and of ActRecTut subject 1 (10 channels) reach it under their own regime, and every time point of a 20-channel Gaussian series with a 3-sigma mean shift, on which AutoPlait finds a single regime.

Implementation: Python translation, compiled with numba, of the C code of Matsubara et al. (version of June 18, 2014), random draws included: it returns the segmentation of the C binary built with GCC on Linux. Each channel is z-normalised in float32, as the C code reads its input. Unlike the binary, the translation has no limit on the number of channels, of regimes or of segments, and sets a constant channel to zero.

Reference: Matsubara, Sakurai & Faloutsos (2014), AutoPlait: Automatic Mining of Co-evolving Time Sequences, SIGMOD.

API reference#

This module provides an aeon-compatible wrapper for the AutoPlait algorithm.

class AutoPlaitDetector(*, n_cps=None, axis=0)[source]#

Bases: BaseSegmenter

AutoPlait state detection: regimes of hidden Markov models chosen by MDL.

AutoPlait [1] describes the series as segments, each generated by one of a few regimes; a regime is a hidden Markov model with diagonal Gaussian emissions, and segments of the same regime share it. The number of regimes, the number of states of each HMM and the cut points are chosen by minimising the total description length (MDL) of the models and of the data. Starting from a single regime, AutoPlait tries to split each regime in two: seeds of length ceil(n / 10) initialise two HMMs, a cut point search (a Viterbi pass over the two models, with a switching probability per regime) assigns each part of the regime to one of them, and the two steps alternate. The split is kept when it shortens the description by more than 3 % of the cost of the regime.

Parameters:
  • n_cps (int or None, default=None) – Deprecated and ignored. AutoPlait chooses the number of segments and regimes itself and has no guided mode, so this value has never changed the output. Passing it emits a FutureWarning at fit; it will be removed in a future release.

  • axis (int) – Time axis: rows with 0, columns with 1.

n_regimes_#

Number of regimes of the last series segmented by predict.

Type:

int

cost_#

Total description length, in bits, of that segmentation.

Type:

float

Notes

The label of a time point is the number of the AutoPlait regime its segment belongs to: segments of the same regime share a label, and each change point is the first index of a segment.

The algorithm is a Python translation, compiled with numba, of the C code of the authors [2] (version of June 18, 2014), random draws included: it returns the segmentation of the C binary built with GCC on Linux. Each channel is z-normalised in float32, as the C code reads its input. Unlike the binary, the translation has no limit on the number of channels, of regimes or of segments, and sets a constant channel to zero.

The C code floors the log-density of an observation, summed over its channels, at \(\log 10^{-6}\). With many channels the observations reach this floor under every model, which can no longer be told apart: on a 20-channel Gaussian series with a 3-sigma mean shift, AutoPlait finds a single regime.

References

set_fit_request(*, axis='$UNCHANGED$')#

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 (Union[bool, None, str]) – Metadata routing for axis parameter in fit.

Returns:

self – The updated object.

Return type:

AutoPlaitDetector

set_predict_request(*, axis='$UNCHANGED$')#

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 (Union[bool, None, str]) – Metadata routing for axis parameter in predict.

Returns:

self – The updated object.

Return type:

AutoPlaitDetector