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:
__init__(unlabeled, labeling, annotation)[source]
Parameters:
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:
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:

annotation

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:

states

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:

transitions

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:

change_points

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:
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]]

__iter__()[source]

Iterate over the unlabeled data.

Returns an iterator for the underlying unlabeled data points.

Returns:

Iterator over the unlabeled data elements.

Return type:

Iterator[TypeVar(DataT)]

__len__()[source]

Get the length of the unlabeled data.

Returns the number of data points in the unlabeled provider.

Returns:

Number of data points in the unlabeled data.

Return type:

int