tsseg.algorithms.e2usd package
E2USD — Efficient-yet-Effective Unsupervised State Detection.
Description
E2USD combines two key ideas for scalable, accurate unsupervised state detection in multivariate time series:
DDEM (Decomposed Dual-view Embedding Module) — a lightweight encoder that compresses sliding windows into low-dimensional representations using FFT-based compression and a decomposed contrastive learning objective.
DPGMM clustering — a Dirichlet Process Gaussian Mixture Model that automatically determines the number of states from the learned embeddings.
A False Negative Cancellation Contrastive Learning method (FNCCLearning) is used to counteract false negatives and produce cluster-friendly embedding spaces.
Parameters
Name |
Type |
Default |
Description |
|---|---|---|---|
|
int |
|
Size of the sliding window. |
|
int |
|
Step size of the sliding window. |
|
int |
|
Maximum number of states for DPGMM clustering. |
|
float |
|
Concentration parameter for DPGMM. |
|
int |
|
Training batch size. |
|
int |
|
Number of optimisation steps. |
|
float |
|
Learning rate. |
|
int |
|
Depth of the DDEM encoder network. |
|
int |
|
Number of output channels of the encoder. |
|
int |
|
Dimension of the CNN output before the final linear layer. |
|
int |
|
Kernel size for CNN convolutions. |
|
bool / None |
|
Force GPU usage ( |
|
int / None |
|
Random seed. |
|
int |
|
Time axis. |
Usage
from tsseg.algorithms import E2USDDetector
detector = E2USDDetector(window_size=256, n_states=10, nb_steps=20)
states = detector.fit_predict(X)
Implementation: Adapted from AI4CTS/E2Usd. No licence found in original repository.
Reference: Lai, Zhao, Li, Qian, Zhang & Jensen (2024), E2Usd: Efficient-yet-effective Unsupervised State Detection for Multivariate Time Series, WWW.
Submodules
tsseg.algorithms.e2usd.detector module
This module provides an aeon-compatible wrapper for the E2USD algorithm.
- class tsseg.algorithms.e2usd.detector.E2USDDetector(axis=0, window_size=256, step=50, n_states=20, alpha=1000.0, batch_size=1, nb_steps=20, lr=0.003, depth=1, out_channels=4, reduced_size=80, kernel_size=3, use_gpu=None, random_state=None)[source]
Bases:
BaseSegmenterA wrapper for the E2USD algorithm, compatible with the aeon library.
E2USD uses a deep learning based encoder to learn representations of time series windows, which are then clustered to identify states.
- Parameters:
axis (int) – Axis along which to segment if passed a multivariate series (2D input). Default is 0, assuming shape (n_timepoints, n_channels).
window_size (int, default=256) – The size of the sliding window.
step (int, default=50) – The step size of the sliding window.
n_states (int, default=20) – The maximum number of states for the DPGMM clustering.
alpha (float, default=1e3) – The concentration parameter for the DPGMM clustering.
batch_size (int, default=1) – Batch size for training the neural network.
nb_steps (int, default=20) – Number of optimization steps for training.
lr (float, default=0.003) – Learning rate for the optimizer.
depth (int, default=1) – Depth of the DDEM Network.
out_channels (int, default=4) – Number of output channels of the encoder.
reduced_size (int, default=80) – Size of the output of the CNN before the final linear layer.
kernel_size (int, default=3) – Kernel size for the convolutions in the CNN.
use_gpu (bool, optional) – Whether to use GPU if available. If None, it will be auto-detected.
random_state (int, optional) – Random state for reproducibility.
- set_fit_request(*, axis: bool | None | str = '$UNCHANGED$') E2USDDetector
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$') E2USDDetector
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.
tsseg.algorithms.e2usd.e2usd module
- class tsseg.algorithms.e2usd.e2usd.DDEM(win_size, batch_size, nb_steps, lr, channels, depth, reduced_size, out_channels, kernel_size, in_channels, cuda, gpu, M, N, win_type)[source]
Bases:
BasicEncoder
- class tsseg.algorithms.e2usd.e2usd.DPGMM(n_states, alpha=1000.0)[source]
Bases:
BasicClusteringClass
- class tsseg.algorithms.e2usd.e2usd.E2USD(win_size, step, encoder, clustering_component, verbose=False)[source]
Bases:
object- property change_points
- property embedding_label
- property embeddings
- property state_seq
- property velocity
- class tsseg.algorithms.e2usd.e2usd.E2USD_Adaper(params)[source]
Bases:
BasicEncoderClass