labeled_data
Abstract interface for labeled data providers.
- class pysatl_cpd.data.providers.labeled.labeled_data.LabeledData(unlabeled, labeling, annotation)[source]
Bases:
Generic[DataT,AnnotationT],DataProvider[DataT,AnnotationT]Base class for labeled sequential data.
- Parameters:
unlabeled (
DataProvider[TypeVar(DataT),UnlabeledTimeseriesAnnotation]) – Unlabeled data provider containing the time series data.labeling (
Iterable[SegmentInfo]) – Iterable of segment information for labeling.annotation (
TypeVar(AnnotationT, bound=TimeseriesAnnotation, covariant=True)) – Annotation associated with the labeled data.
- __init__(unlabeled, labeling, annotation)[source]
- Parameters:
unlabeled (DataProvider[DataT, UnlabeledTimeseriesAnnotation])
labeling (Iterable[SegmentInfo])
annotation (AnnotationT)
- Return type:
None
- classmethod from_unlabeled_data(unlabeled, segment_info, annotation)[source]
Create a labeled data instance from unlabeled data.
Alternative constructor that builds labeling from segment info.
- Parameters:
unlabeled (
DataProvider[TypeVar(DataT),UnlabeledTimeseriesAnnotation]) – Unlabeled data provider containing the time series data.segment_info (
Iterable[SegmentInfo]) – Iterable of segment information for labeling.annotation (
TypeVar(A, bound=TimeseriesAnnotation)) – Annotation to associate with the new labeled data instance.
- Returns:
LabeledData instance initialized from the provided unlabeled data.
- Return type:
LabeledData[TypeVar(DataT),TypeVar(A, bound=TimeseriesAnnotation)]
- property annotation: AnnotationT
Return the annotation of the labeled data.
Provides access to the associated annotation.
- Returns:
Annotation instance for the labeled data.
- Return type:
- property unlabeled: DataProvider[DataT, UnlabeledTimeseriesAnnotation]
Return the unlabeled data provider.
Provides access to the underlying unlabeled time series data.
- Returns:
Unlabeled data provider instance.
- Return type:
provider
- property segments_labeling: SegmentsLabeling
Return the segments labeling information.
Provides access to the segments labeling instance.
- Returns:
SegmentsLabeling instance for the labeled data.
- Return type:
labeling
- property states: set[StateDescriptor]
Return the set of states in the segments labeling.
Extracts states from the underlying segments labeling.
- Returns:
Set of state descriptors present in the data.
- Return type:
- property transitions: set[TransitionDescriptor]
Return the set of transitions in the segments labeling.
Extracts transitions from the underlying segments labeling.
- Returns:
Set of transition descriptors present in the data.
- Return type:
- property change_points: tuple[int, ...]
Return the tuple of change point indices.
Change points are the start indices of segments after the first.
- Returns:
Tuple of zero-based change point indices.
- Return type:
- cut(start, stop, *, annotation=None)[source]
Cut a slice of the labeled data.
Creates a new labeled data instance for the specified slice.
- Parameters:
start (
int) – Start index of the slice (inclusive).stop (
int) – Stop index of the slice (inclusive).annotation (
Optional[TypeVar(AnnotationT, bound=TimeseriesAnnotation, covariant=True)]) – Optional annotation for the sliced data; uses default if None.
- Returns:
New labeled data instance for the sliced range.
- Return type:
LabeledData[TypeVar(DataT),TypeVar(AnnotationT, bound=TimeseriesAnnotation, covariant=True)]
- classmethod merge(providers, annotation_builder=None)[source]
Merge multiple labeled data instances into one.
Combines unlabeled data, labeling, and annotations from providers.
- Parameters:
providers (
Sequence[Self]) – Sequence of labeled data instances to merge.annotation_builder (
Callable[[Sequence[TypeVar(AnnotationT, bound=TimeseriesAnnotation, covariant=True)]],TypeVar(AnnotationT, bound=TimeseriesAnnotation, covariant=True)] |None) – Optional callable to build merged annotation; uses default if None.
- Returns:
Merged labeled data instance containing all input data.
- Return type:
LabeledData[TypeVar(DataT),TypeVar(AnnotationT, bound=TimeseriesAnnotation, covariant=True)]
- query_segments(filter_fn=None)[source]
Query segments matching a filter function.
Returns labeled data instances for each matching segment.
- Parameters:
filter_fn (
Callable[[SegmentInfo],bool] |None) – Optional filter function to select segments; matches all if None.- Returns:
Sequence of labeled data instances for matching segments.
- Return type:
Sequence[LabeledData[TypeVar(DataT),SegmentAnnotation]]
- query_bisegments(filter_fn=None)[source]
Query bisegments matching a filter function.
Returns labeled data instances for each matching bisegment.
- Parameters:
filter_fn (
Callable[[BisegmentInfo],bool] |None) – Optional filter function to select bisegments; matches all if None.- Returns:
Sequence of labeled data instances for matching bisegments.
- Return type:
Sequence[LabeledData[TypeVar(DataT),BisegmentAnnotation]]