ESPRESSO#

ESPRESSO – Entropy and Shape-aware Time Series Segmentation.

Description#

ESPRESSO combines the temporal shape of each channel, read from its matrix profile, with an entropy criterion computed over all channels to segment multi-dimensional time series:

  1. For each channel, compute the matrix profile of the subsequences of length window_size (z-normalised Euclidean distance, FFT-based self-join written in NumPy; stumpy is not used). It links each subsequence to its nearest neighbour by an arc.

  2. Extend these arcs along chains of nearest neighbours for at most chain_len rounds, and add to every position an arc spans a weight that decreases with the arc length. The result is the channel’s semantic density curve: few arcs cross a segment boundary.

  3. Smooth each density curve and take its local minima, at least peak_distance_fraction times the series length apart and ranked by prominence, as candidate change points.

  4. Among the candidates of each channel, greedily add the one that maximises the information gain (entropy reduction, as in IGTS) of the segmentation of all channels. The change points are the first n_segments - 1 candidates picked, from the channel whose picks reach the highest gain; there are fewer when that channel has fewer candidates.

The matrix profile contains Euclidean distances. Earlier versions applied an extra square root after computing the minimum distance; nearest-neighbour indices are unchanged by its removal. Chaining sums these distances against a budget of twice the largest profile value, so changing their units can affect the semantic density from the third expansion onward. Finite nonnegative profiles give the same density through two expansions. This correction restores the distance units of the MATLAB source; it does not establish a detection-quality improvement or complete numerical parity with that source.

Type: change point detection
Supervision: semi-supervised (n_segments required)
Scope: univariate and multivariate
Complexity: \(O(d\,n^{2}\log n)\): one matrix profile per channel, with an FFT for each subsequence

The profile excludes neighbours within round(window_size / 4) points, using MATLAB’s half-away-from-zero rounding. Extended chains must span strictly more than window_size / 4 points, without rounding that threshold. These are separate rules in the original implementation.

Parameters#

Name

Type

Default

Description

window_size

int

64

Subsequence length for the matrix profile (>= 4, at most half the series length).

chain_len

int

3

Iterations for expanding arc sets.

n_segments

int / None

None

Target number of segments (1 = no change point); required.

peak_distance_fraction

float

0.01

Minimum spacing between peaks as a fraction of the series length.

axis

int

0

Time axis.

random_state

int / None

None

Seed of the order in which subsequences are visited for the matrix profile; it changes the result only when distances tie (exactly repeated patterns). None draws a fresh seed at each predict.

Usage#

from tsseg.algorithms import EspressoDetector

detector = EspressoDetector(window_size=64, chain_len=5, n_segments=4)
change_points = detector.fit_predict(X)

Implementation: Python translation of the authors’ MATLAB code (cruiseresearchgroup/ESPRESSO), which is not shipped with tsseg. No licence found in the original repository. Origin: translated from the original MATLAB code.

Reference: Deldari, Smith, Sadri & Salim (2020), ESPRESSO: Entropy and ShaPe awaRe timE-Series SegmentatiOn for Processing Heterogeneous Sensor Data, Proc. ACM IMWUT 4(3) (UbiComp 2020).

API reference#

ESPRESSO change-point detector implemented purely in Python.

class EspressoDetector(*, window_size=64, chain_len=3, n_segments=None, peak_distance_fraction=0.01, random_state=None, axis=0)[source]#

Bases: BaseSegmenter

Segment time series using the ESPRESSO change-point detection algorithm.

Parameters:
  • window_size (int) – Length of the subsequences used to compute the matrix profile; must be at least 4 and at most half the series length.

  • chain_len (int) – Number of iterations used when expanding arc sets to build the semantic density matrix.

  • n_segments (int | None) – Target number of segments to produce during prediction. Must be supplied before calling fit; 1 returns no change point.

  • peak_distance_fraction (float) – Fraction of the input length that enforces a minimum spacing between detected peaks (matches the MATLAB reference implementation).

  • axis (int) – Axis corresponding to the time dimension in the input array.

  • random_state (int | None) – Seed of the random order in which the subsequences are visited to compute the matrix profile. The order only matters when distances tie (for instance on exactly repeated patterns): the nearest neighbour kept for a tie, and so the change points, can then change with the seed. None draws a fresh seed at each call to predict.

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:

EspressoDetector

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:

EspressoDetector