mvtsa.segmentation.MergeTree#

class mvtsa.segmentation.MergeTree(initial, removed, criterion, total_cost, n_samples, meta=<factory>)[source]#

Bases: object

Hierarchy of segmentations produced by bottom-up merging.

Attributes:
initialarray of int

Change points of the initial (finest) segmentation.

removedarray of int

Change point removed by every merge step, in merge order.

criterionarray of float

Merge criterion (cost increase) of every step.

total_costarray of float

total_cost[k] is the total cost after k merges (total_cost[0] is the cost of the initial segmentation).

n_samplesint
cost_curve()[source]#

Total cost as a function of the number of segments.

cut(n_segments)[source]#

Change points of the level with n_segments segments.

levels(max_segments=None)[source]#

Change points of every level from 1 to max_segments segments.

persistence(normalize=True, scale='cost')[source]#

Lifetime of every initial change point in the merge hierarchy.

With scale="cost" (default) a boundary is born at level 0 and dies at the merge cost at which it is removed – the running maximum of the merge criterion, so that the levels form a filtration as in topological persistence. With scale="rank" the lifetime is the number of merges it survives. Boundaries that survive to the coarsest level get the maximum value; normalize divides by that maximum. Large values mark stable, important change points.

rank()[source]#

Importance rank of every initial change point: the number of segments of the coarsest level that still contains it (2 for the most important boundary, which is the last one removed).