tsseg.algorithms.tglad package

tGLAD — temporal Graph-difference change point detection.

Description

tGLAD segments multivariate time series by tracking the evolution of conditional independence (CI) graphs over time. A sliding window converts the series into overlapping intervals; the uGLAD sparse graph recovery model (multitask mode) recovers a precision matrix (CI graph) for each interval simultaneously. A second-order trajectory-tracking algorithm measures graph-difference scores, and an allocation algorithm produces the final segmentation.

Type: change point detection
Supervision: fully unsupervised
Scope: univariate and multivariate
Requires: PyTorch, networkx

Parameters

Name

Type

Default

Description

window_size

int

512

Time steps per uGLAD window.

stride

int

128

Step between successive windows.

batch_size

int

8

Windows processed together by the multitask solver.

threshold

float

0.5

Min Frobenius distance to trigger a change point.

min_spacing

int / None

None

Min distance between emitted CPs (default: stride).

epochs

int

2000

uGLAD training epochs per batch.

learning_rate

float

0.001

Optimiser learning rate.

glad_iterations

int

5

Unrolled GLAD iterations.

eval_offset

float

0.1

Eigenvalue regularisation for batch covariance.

verbose

bool

False

Print progress information.

axis

int

0

Time axis.

Usage

from tsseg.algorithms import TGLADDetector

detector = TGLADDetector(window_size=256, stride=64, threshold=0.4)
labels = detector.fit_predict(X)

Implementation: Origin: new code. Inspired by the tGLAD paper.

Reference: Imani & Shrivastava (2023), Are uGLAD? Time will tell!

Submodules

tsseg.algorithms.tglad.detector module

TGLAD change point detector.

class tsseg.algorithms.tglad.detector.TGLADDetector(*, window_size=512, stride=128, batch_size=8, threshold=0.5, min_spacing=None, epochs=100, learning_rate=0.001, glad_iterations=5, eval_offset=0.1, verbose=False, axis=0)[source]

Bases: BaseSegmenter

Graph-difference based change point detector using uGLAD.

The detector follows the batching procedure described in the original tGLAD repository. The time-series is converted to overlapping windows, each window yields a precision matrix via the uGLAD multitask solver.

The change point score is calculated based on the second derivative of the sum of partial correlations derived from the precision matrices, faithfully mirroring the original implementation. Change points are emitted whenever the score exceeds threshold.

Parameters:
  • window_size (int) – Number of time steps per uGLAD window.

  • stride (int) – Step between successive windows.

  • batch_size (int) – Number of windows processed together by the multitask solver.

  • threshold (float) – Minimum Frobenius distance between adjacent precision matrices that triggers a change point.

  • min_spacing (int | None) – Minimum distance (in samples) required between two emitted change points. Defaults to the stride when None.

  • epochs (int) – Number of uGLAD training epochs per batch.

  • learning_rate (float) – Optimiser learning rate.

  • glad_iterations (int) – Number of unrolled GLAD iterations (L in the paper).

  • eval_offset (float) – Eigenvalue regularisation applied to batch covariance matrices.

  • verbose (bool) – Forward progress flag passed through to the uGLAD routines.

  • axis (int) – Time axis of X. 0 assumes (n_timepoints, n_features).

property change_points_: ndarray

Return change points detected during fit().

property change_scores_: ndarray

Frobenius distances for each window.

set_fit_request(*, axis: bool | None | str = '$UNCHANGED$') TGLADDetector

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 (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for axis parameter in fit.

Returns:

self – The updated object.

Return type:

object

set_predict_request(*, axis: bool | None | str = '$UNCHANGED$') TGLADDetector

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 (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for axis parameter in predict.

Returns:

self – The updated object.

Return type:

object

Module contents