tsseg.algorithms.espresso package
ESPRESSO — Entropy and Shape-aware Time Series Segmentation.
Description
ESPRESSO exploits both entropy and temporal shape properties to segment multi-dimensional time series. The method builds a semantic density matrix from the matrix profile using an arc-curve expansion procedure:
Compute the matrix profile with
stumpy.Iteratively expand arc sets (controlled by
chain_len) to accumulate segment-boundary evidence.Detect peaks in the resulting density curve; peaks signal change points.
ESPRESSO differs from methods that focus exclusively on statistical or temporal properties.
n_segments required)Parameters
Name |
Type |
Default |
Description |
|---|---|---|---|
|
int |
|
Subsequence length for the matrix profile (>= 4). |
|
int |
|
Iterations for expanding arc sets. |
|
int / None |
|
Target number of segments (>= 2 at predict time). |
|
float |
|
Minimum spacing between peaks as a fraction of the series length. |
|
int |
|
Time axis. |
|
int / None |
|
Seed for the internal RNG. |
Usage
from tsseg.algorithms import EspressoDetector
detector = EspressoDetector(window_size=64, chain_len=5, n_segments=4)
labels = detector.fit_predict(X)
Implementation: Reimplemented from the original ESPRESSO paper. Origin: new code.
Reference: Deldari, Smith, Sadri & Salim (2020), ESPRESSO: Entropy and ShaPe awaRe timE-Series SegmentatiOn, UbiComp.
Submodules
tsseg.algorithms.espresso.detector module
ESPRESSO change-point detector implemented purely in Python.
- class tsseg.algorithms.espresso.detector.EspressoDetector(window_size=64, chain_len=3, *, n_segments=None, peak_distance_fraction=0.01, axis=0, random_state=None)[source]
Bases:
BaseSegmenterSegment time series using the ESPRESSO change-point detection algorithm.
- Parameters:
subsequence_length (int, default=64) – Length of the subsequences used to compute the matrix profile; must be at least 4.
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 and be greater than or equal to 2 when callingpredict.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 for the internal random number generator used when sampling subsequences for the matrix profile.
- set_fit_request(*, axis: bool | None | str = '$UNCHANGED$') EspressoDetector
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: bool | None | str = '$UNCHANGED$') EspressoDetector
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.