tsseg.algorithms package

Subpackages

Submodules

tsseg.algorithms.utils module

tsseg.algorithms.utils.aggregate_change_points(all_cps, n_cp, tolerance=0, signal_len=None)[source]

Aggregate change points from multiple dimensions with tolerance.

Parameters:
  • all_cps (list[int]) – List of all change point indices detected across all dimensions.

  • n_cp (int) – Number of change points to return.

  • tolerance (int | float) – Tolerance window for grouping change points. If float < 1.0, it is interpreted as a fraction of signal_len.

  • signal_len (int | None) – Length of the signal, required if tolerance is a fraction.

Returns:

Sorted array of aggregated change point indices.

Return type:

ndarray

tsseg.algorithms.utils.create_state_labels(changepoints, n_timepoints)[source]

Create state labels from a list of changepoints.

Parameters:
  • changepoints (list of int) – List of changepoint indices. The first element should be 0.

  • n_timepoints (int) – The total number of timepoints in the series.

Returns:

A 1D array of state labels of shape (n_timepoints,).

Return type:

np.ndarray

tsseg.algorithms.utils.extract_cps(label_seq)[source]

Extract changepoints from a sequence of state labels.

A changepoint is defined as the first timepoint of a new state.

Parameters:

label_seq (ndarray) – A 1D array of state labels of shape (n_timepoints,).

Returns:

A 1D array of changepoint indices.

Return type:

ndarray

tsseg.algorithms.utils.multivariate_l2_norm(signal)[source]

Compute the L2 norm across dimensions for a multivariate signal.

Parameters:

signal (ndarray) – Multivariate signal of shape (n_timepoints, n_channels).

Returns:

Univariate signal of shape (n_timepoints,) representing the L2 norm.

Return type:

ndarray

Module contents