Skip to content

InformationGainSegmentation

InformationGainSegmentation

class InformationGainSegmentation(k_max: int = 10, step: int = 5)[source]

Information Gain based Temporal Segmentation (IGTS) Estimator.

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

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

IGTS uses top-down search method to greedily find the next change point location that creates the maximum information gain. Once this is found, it repeats the process until it finds k_max splits of the time series.

Note

IGTS does not work very well for univariate series but it can still be used if the original univariate series are augmented by an extra feature dimensions. A technique proposed in the paper [1] is to subtract the series from its largest element and append to the series.

Parameters:
k_max: int, default=10

Maximum number of change points to find. The number of segments is thus k+1.

stepint, default=5

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.

Attributes:
change_points_: list of int

Locations of change points as integer indexes. By convention change points include the identity segmentation, i.e. first and last index + 1 values.

intermediate_results_: list of ``ChangePointResult``

Intermediate segmentation results for each k value, where k=1, 2, …, k_max

Notes

Based on the work from [1]. - alt. py implementation: https://github.com/cruiseresearchgroup/IGTS-python - MATLAB version: https://github.com/cruiseresearchgroup/IGTS-matlab - paper available at:

References

[1] (1,2)

Sadri, Amin, Yongli Ren, and Flora D. Salim. “Information gain-based metric for recognizing transitions in human activities.”, Pervasive and Mobile Computing, 38, 92-109, (2017). https://www.sciencedirect.com/science/article/abs/pii/S1574119217300081

Examples

>>> from sktime.detection.datagen import piecewise_normal_multivariate
>>> from sklearn.preprocessing import MinMaxScaler
>>> X = piecewise_normal_multivariate(
... lengths=[10, 10, 10, 10],
... means=[[0.0, 1.0], [11.0, 10.0], [5.0, 3.0], [2.0, 2.0]],
... variances=0.5,
... )
>>> X_scaled = MinMaxScaler(feature_range=(0, 1)).fit_transform(X)
>>> from sktime.detection.igts import InformationGainSegmentation
>>> igts = InformationGainSegmentation(k_max=3, step=2)
>>> y = igts.fit_predict(X_scaled)

Methods

check_is_fitted([method_name])

Check if the estimator has been fitted.

clone()

Obtain a clone of the object with same hyper-parameters and config.

clone_tags(estimator[, tag_names])

Clone tags from another object as dynamic override.

create_test_instance([parameter_set])

Construct an instance of the class, using first test parameter set.

create_test_instances_and_names([parameter_set])

Create list of all test instances and a list of names for them.

fit(X[, y])

Fit method for compatibility with sklearn-type estimator interface.

fit_predict(X[, y])

Perform segmentation.

get_class_tag(tag_name[, tag_value_default])

Get class tag value from class, with tag level inheritance from parents.

get_class_tags()

Get class tags from class, with tag level inheritance from parent classes.

get_config()

Get config flags for self.

get_fitted_params([deep])

Get fitted parameters.

get_param_defaults()

Get object's parameter defaults.

get_param_names([sort])

Get object's parameter names.

get_params([deep])

Get a dict of parameters values for this object.

get_tag(tag_name[, tag_value_default, ...])

Get tag value from instance, with tag level inheritance and overrides.

get_tags()

Get tags from instance, with tag level inheritance and overrides.

get_test_params([parameter_set])

Return testing parameter settings for the estimator.

is_composite()

Check if the object is composed of other BaseObjects.

load_from_path(serial)

Load object from file location.

load_from_serial(serial)

Load object from serialized memory container.

predict(X[, y])

Perform segmentation.

reset()

Reset the object to a clean post-init state.

save([path, serialization_format])

Save serialized self to bytes-like object or to (.zip) file.

set_config(**config_dict)

Set config flags to given values.

set_params(**params)

Set the parameters of this object.

set_random_state([random_state, deep, ...])

Set random_state pseudo-random seed parameters for self.

set_tags(**tag_dict)

Set instance level tag overrides to given values.

to_classification(change_points)

Convert change point locations to a classification vector.

to_clusters(change_points)

Convert change point locations to a clustering vector.