InformationGain (IGTS)#

IGTS – Information Gain based Temporal Segmentation.

Description#

IGTS is a top-down greedy algorithm that locates the change point maximising the information gain at each step, then repeats on the resulting sub-signals. It works best on multivariate series where distribution shifts across channels provide discriminative evidence.

Warning

IGTS does not perform well on univariate series without augmentation.

Type: change point detection
Supervision: unsupervised or semi-supervised
Scope: multivariate (primarily)
Complexity: \(O(d\,n + K^{2}\,d\,n/s)\), where K is k_max and s is step: each of the K greedy steps scores the \(n/s\) candidate locations from cumulative sums, over at most \(K + 1\) segments

Parameters#

Name

Type

Default

Description

k_max

int

10

Maximum number of change points. Fewer are returned when every candidate location (the multiples of step) is already a change point.

step

int

5

Stride for candidate locations.

axis

int

0

Time axis (rows with 0, columns with 1).

Usage#

from tsseg.algorithms import InformationGainDetector

detector = InformationGainDetector(k_max=8, step=5)
change_points = detector.fit_predict(X)

Implementation: Adapted from aeon. BSD 3-Clause.

Reference: Sadri, Ren & Salim (2017), Information Gain-based Metric for Recognizing Transitions in Human Activities, Pervasive and Mobile Computing.

API reference#

Information Gain-based Temporal Segmenter.

Information Gain Temporal Segmentation (_IGTS) is a method for segmenting multivariate time series based off reducing the entropy in each segment.

The amount of entropy lost by the segmentations made is called the Information Gain (IG). The aim is to find the segmentations that have the maximum information gain for any number of segmentations.

class InformationGainDetector(*, k_max=10, step=5, axis=0)[source]#

Bases: BaseSegmenter

Information Gain based Temporal Segmentation (IGTS) Estimator.

IGTS is an unsupervised method for segmenting time series into non-overlapping segments by locating change points that maximise the information gain.

Information gain (IG) is defined as the amount of entropy lost by the segmentation. The aim is to find the segmentation that has the maximum information gain for a specified number of segments.

IGTS uses a top-down search to greedily find the next change point that creates the maximum information gain. Once found, the process repeats until k_max splits have been made, or until every candidate position (the multiples of step) is already a change point, in which case fewer than k_max change points are returned.

For univariate input the series is automatically augmented with its normalised complement channel (Eq. 12-13 of [1]) so that entropy can vary across segments.

Parameters:
  • k_max (int) – Maximum number of change points to find, hence at most k_max + 1 segments. 0 returns no change point.

  • step (int) – Step size, or stride for selecting candidate locations of change points. For example a step=5 would produce candidates [0, 5, 10, …]. Has the same meaning as step in range function.

  • axis (int) – Time axis: rows with 0, columns with 1.

intermediate_results_#

One entry per change point added, in the order of the search: k (0 for the first change point), the information gain score and the change_points found so far, with the boundaries 0 and n.

Type:

list of ChangePointResult

Notes

Based on the work from [1]. - alt. py implementation: cruiseresearchgroup/IGTS-python - MATLAB version: cruiseresearchgroup/IGTS-matlab

References

Examples

>>> import numpy as np
>>> from tsseg.algorithms import InformationGainDetector
>>> rng = np.random.default_rng(0)
>>> X = np.concatenate([rng.normal(0, 1, (100, 2)), rng.normal(5, 1, (100, 2))])
>>> X = np.concatenate([X, rng.normal(0, 1, (100, 2)) + [5, -5]])
>>> igts = InformationGainDetector(k_max=2, step=5)
>>> igts.fit_predict(X)
array([100, 200])
set_fit_request(*, axis='$UNCHANGED$')#

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 (Union[bool, None, str]) – Metadata routing for axis parameter in fit.

Returns:

self – The updated object.

Return type:

InformationGainDetector

set_predict_request(*, axis='$UNCHANGED$')#

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 (Union[bool, None, str]) – Metadata routing for axis parameter in predict.

Returns:

self – The updated object.

Return type:

InformationGainDetector