ClassifierPipeline#
- class capymoa.stream.preprocessing.ClassifierPipeline[source]#
Bases:
BasePipeline
,Classifier
Classifier pipeline that (in addition to the functionality of BasePipeline) also acts as a classifier.
- add_classifier(classifier: Classifier)[source]#
Adds a classifier to the end of the current pipeline
Parameters#
- classifier: Classifier
The classifier to add to the pipeline
Returns#
- ClassifierPipeline
self
- train(instance: LabeledInstance)[source]#
The train function of the Classifier. Calls pass_forward internally.
Parameters#
- instance: LabeledInstance
The instance to train on
- predict(instance: Instance) int | None [source]#
The predict function of the classifier. Calls pass_forward_predict internally and returns the prediction.
Parameters#
- instance: Instance
The instance to predict
Returns#
- Optional[LabelIndex]
The prediction of the pipeline
- predict_proba(
- instance: Instance,
Return probability estimates for each label.
- Parameters:
instance – The instance to estimate the probabilities for.
- Returns:
An array of probabilities for each label or
None
if the classifier is unable to make a prediction.
- __init__(
- pipeline_elements: List[PipelineElement] | None = None,
Initializes the base pipeline with a list of pipeline elements.
Parameters#
- pipeline_elements: List[PipelineElement]
The elements the pipeline consists of
- add_drift_detector(
- drift_detector: BaseDriftDetector,
- get_drift_detector_input_func: Callable,
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
- add_pipeline_element(
- element: PipelineElement,
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,
Adds a transformer to the end of the current pipeline
Parameters#
- transformer: Transformer
The transformer to add
Returns#
- BasePipeline
self
- pass_forward(
- instance: Instance,
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,
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
- random_seed: int#
The random seed for reproducibility.
When implementing a classifier ensure random number generators are seeded.