segments_labeling
Segment labeling utilities for labeled time series providers.
- class pysatl_cpd.data.providers.labeled.segments_labeling.SegmentsLabeling(segments)[source]
Bases:
Sequence[SegmentInfo]Labeled segments with query and transformation capabilities.
This class provides a sequence of segment information objects with methods for querying segments and bisegments, cutting slices, merging labelings, and converting to/from DataFrames.
- Parameters:
segments (
Iterable[SegmentInfo]) – Iterable of segment information objects.
- __init__(segments)[source]
- Parameters:
segments (Iterable[SegmentInfo])
- Return type:
None
- query_segments(filter_fn=None)[source]
Query segments by optional filter.
- Parameters:
filter_fn (
Callable[[SegmentInfo],bool] |None) – Optional predicate function for segment filtering.- Returns:
Filtered sequence of segment information.
- Return type:
- query_bisegments(filter_fn=None)[source]
Query bisegments by optional filter.
- Parameters:
filter_fn (
Callable[[BisegmentInfo],bool] |None) – Optional predicate function for bisegment filtering.- Returns:
Filtered sequence of bisegment information.
- Return type:
- property states: set[StateDescriptor]
Return the set of states represented by the labeling.
- Returns:
Set of unique state descriptors in this labeling.
- Return type:
- property transitions: set[TransitionDescriptor]
Return transitions between consecutive segments.
- Returns:
Set of unique transition descriptors between consecutive segments.
- Return type:
- cut(start, stop)[source]
Cut a slice from the labeling.
- Parameters:
- Returns:
New labeling containing the cut portion.
- Return type:
- Raises:
ValueError – If start is negative, stop is less than start, or stop exceeds the data length.
- classmethod merge(labelings)[source]
Merge multiple labelings into one.
- Parameters:
labelings (
Sequence[SegmentsLabeling]) – Sequence of labelings to merge.- Returns:
Single merged labeling with adjusted offsets.
- Return type:
- __getitem__(index)[source]
- Overloads:
self, index (int) → SegmentInfo
self, index (slice) → Self
- Parameters:
- Return type:
Return one segment or a sliced labeling.
- property data_len: int
Return the total covered data length.
- Returns:
Total data length across all segments.
- Return type:
length
- classmethod from_dataframe(frame, segment_num_col='segment', segment_start_col='start', segment_end_col='end')[source]
Create labeling from a DataFrame.
- Parameters:
- Returns:
New labeling instance constructed from the DataFrame.
- Return type:
Self