mvtsa.Segmentation#
- class mvtsa.Segmentation(change_points, n_samples, labels=None, memberships=None, scores=None, cost=None, meta=<factory>)[source]#
Bases:
objectA segmentation of one series.
- Parameters:
- change_points
arrayofint Sorted start indices of the 2nd, 3rd, … segment (
0 < t < T).- n_samples
int Length
Tof the segmented series.- labels
arrayofint,optional State (regime) label of each segment; segments with the same label belong to the same state.
- memberships
array(T,c),optional Fuzzy memberships of the samples in the segments (fuzzy segmentation).
- scores
array,optional Method-specific score of each change point (e.g. merge cost, change probability, classification score).
- cost
float,optional Total cost of the segmentation (cost-based methods).
- meta
dict Method name, parameters and other diagnostics.
- change_points
Examples
>>> s = Segmentation([3, 7], 10) >>> s.segments [(0, 3), (3, 7), (7, 10)] >>> s.to_labels().tolist() [0, 0, 0, 1, 1, 1, 1, 2, 2, 2]
- property bounds#
[0, t_1, ..., t_{c-1}, T].
- classmethod from_labels(labels, **kwargs)[source]#
Build a segmentation from a per-sample label sequence.
Every run of equal labels becomes a segment; the run labels become the state labels.
>>> Segmentation.from_labels([0, 0, 1, 1, 0]).labels.tolist() [0, 1, 0]
- property segments#
List of half-open
(start, stop)index ranges.
- shift(offset, n_samples=None)[source]#
Change points moved by
offset(used when a method works on a lagged or trimmed copy of the series).
Examples using mvtsa.Segmentation#
Clustering segments: recurring patterns across series