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:
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;stumpyis not used). It links each subsequence to its nearest neighbour by an arc.Extend these arcs along chains of nearest neighbours for at most
chain_lenrounds, 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.Smooth each density curve and take its local minima, at least
peak_distance_fractiontimes the series length apart and ranked by prominence, as candidate change points.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 - 1candidates 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.
n_segments required)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 |
|---|---|---|---|
|
int |
|
Subsequence length for the matrix profile (>= 4, at most half the series length). |
|
int |
|
Iterations for expanding arc sets. |
|
int / None |
|
Target number of segments ( |
|
float |
|
Minimum spacing between peaks as a fraction of the series length. |
|
int |
|
Time axis. |
|
int / 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). |
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:
BaseSegmenterSegment 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 callingfit;1returns 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.Nonedraws a fresh seed at each call topredict.
- set_fit_request(*, axis='$UNCHANGED$')#
Configure whether metadata should be requested to be passed to the
fitmethod.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(seesklearn.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 tofitif provided. The request is ignored if metadata is not provided.False: metadata is not requested and the meta-estimator will not pass it tofit.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.
- set_predict_request(*, axis='$UNCHANGED$')#
Configure whether metadata should be requested to be passed to the
predictmethod.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(seesklearn.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 topredictif provided. The request is ignored if metadata is not provided.False: metadata is not requested and the meta-estimator will not pass it topredict.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.