BasePipeline#

class capymoa.stream.preprocessing.BasePipeline[source]#

Bases: PipelineElement

The base class for other types of pipelines. Supports transformers and drift detectors.

__init__(
pipeline_elements: List[PipelineElement] | None = None,
)[source]#

Initializes the base pipeline with a list of pipeline elements.

Parameters#

pipeline_elements: List[PipelineElement]

The elements the pipeline consists of

add_pipeline_element(
element: PipelineElement,
)[source]#

Adds the provided pipeline element to the end of the pipeline

Parameters#

element: PipelineElement

The element to add to the pipeline

Returns#

BasePipeline

self

add_transformer(
transformer: Transformer,
)[source]#

Adds a transformer to the end of the current pipeline

Parameters#

transformer: Transformer

The transformer to add

Returns#

BasePipeline

self

add_drift_detector(
drift_detector: BaseDriftDetector,
get_drift_detector_input_func: Callable,
)[source]#

Adds a drift detector to the end of the current pipeline

Parameters#

drift_detector: BaseDriftDetector

The drift_detector to add

get_drift_detector_input_func: Callable

The function that prepares the input of the drift detector. The function signature should start with the instance and the prediction. E.g., prediction_is_correct(instance, pred). The output of that function gets passed to the drift detector

Returns#

BasePipeline

self

pass_forward(
instance: Instance,
) Instance[source]#

Passes the instance through the pipeline and returns it. This transforms the instance depending on the transformers in the pipeline

Parameters#

instance: Instance

The instance

Returns#

Instance

The instance that exits the pipeline

pass_forward_predict(
instance: Instance,
prediction: Any = None,
) Tuple[Instance, Any][source]#

Passes the instance through the pipeline and returns it. Also returns the prediction of the pipeline.

Parameters#

instance: Instance

The input instance

prediction: Any

The prediction passed to the pipeline. This can be useful to, e.g., set up a change detection pipeline after the prediction pipeline

Returns#

Tuple[Instance, Any]

The instance that exits the pipeline and the prediction that exits the pipeline. In the case of a BasePipeline, this is most likely the prediction that was given to the function