# `RegressorPipeline`

### *class* capymoa.stream.preprocessing.RegressorPipeline[[source]](https://github.com/adaptive-machine-learning/CapyMOA/blob/3e255b1/src/capymoa/stream/preprocessing/pipeline.py#L659)

Bases: [`BasePipeline`](capymoa.stream.preprocessing.BasePipeline.md#capymoa.stream.preprocessing.BasePipeline), [`Regressor`](capymoa.base.Regressor.md#capymoa.base.Regressor)

Regressor pipeline that (in addition to the functionality of BasePipeline) also acts as a regressor.

#### \_\_init_\_(pipeline_elements: [list](https://docs.python.org/3/builtins/stdtypes.html#list)[[PipelineElement](capymoa.stream.preprocessing.PipelineElement.md#capymoa.stream.preprocessing.PipelineElement)] | [None](https://docs.python.org/3/builtins/constants.html#None) = None, schema: [Schema](capymoa.stream.Schema.md#capymoa.stream.Schema) | [None](https://docs.python.org/3/builtins/constants.html#None) = None, random_seed: [int](https://docs.python.org/3/builtins/functions.html#int) = 1, validate_schema: [bool](https://docs.python.org/3/builtins/functions.html#bool) = True)[[source]](https://github.com/adaptive-machine-learning/CapyMOA/blob/3e255b1/src/capymoa/stream/preprocessing/pipeline.py#L349)

Initializes the base pipeline with a list of pipeline elements.

## Parameters

pipeline_elements: List[PipelineElement]
: The elements the pipeline consists of

schema: Optional[Schema]
: The schema of instances entering the pipeline. Normally left unset,
  in which case it is taken from the first element that knows one.

random_seed: int
: Seed reported to satisfy the learner interface. The pipeline does
  not draw from it; its elements carry their own seeds.

validate_schema: bool
: If True, adding an element whose schema is incompatible with the
  schema leaving the pipeline raises a ValueError.

#### add_drift_detector(drift_detector: [BaseDriftDetector](capymoa.drift.base_detector.BaseDriftDetector.md#capymoa.drift.base_detector.BaseDriftDetector), get_drift_detector_input_func: [Callable](https://docs.python.org/3/library/collections.abc.html#collections.abc.Callable))[[source]](https://github.com/adaptive-machine-learning/CapyMOA/blob/3e255b1/src/capymoa/stream/preprocessing/pipeline.py#L515)

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](capymoa.stream.preprocessing.PipelineElement.md#capymoa.stream.preprocessing.PipelineElement))[[source]](https://github.com/adaptive-machine-learning/CapyMOA/blob/3e255b1/src/capymoa/stream/preprocessing/pipeline.py#L468)

Adds the provided pipeline element to the end of the pipeline

## Parameters

element: PipelineElement
: The element to add to the pipeline

## Returns

BasePipeline
: self

## Raises

ValueError
: If the element’s schema is incompatible with the schema currently
  leaving the pipeline and `validate_schema` is enabled.

#### add_regressor(regressor: [Regressor](capymoa.base.Regressor.md#capymoa.base.Regressor))[[source]](https://github.com/adaptive-machine-learning/CapyMOA/blob/3e255b1/src/capymoa/stream/preprocessing/pipeline.py#L664)

Adds a regressor to the end of the current pipeline

## Parameters

regressor: Regressor
: The regressor to add to the pipeline

## Returns

RegressorPipeline
: self

#### add_transformer(transformer: [Transformer](capymoa.stream.preprocessing.Transformer.md#capymoa.stream.preprocessing.Transformer))[[source]](https://github.com/adaptive-machine-learning/CapyMOA/blob/3e255b1/src/capymoa/stream/preprocessing/pipeline.py#L494)

Adds a transformer to the end of the current pipeline

## Parameters

transformer: Transformer
: The transformer to add

## Returns

BasePipeline
: self

#### *classmethod* from_params(schema: [Any](https://docs.python.org/3/library/typing.html#typing.Any) = None, params: [dict](https://docs.python.org/3/builtins/stdtypes.html#dict)[[str](https://docs.python.org/3/builtins/stdtypes.html#str), [Any](https://docs.python.org/3/library/typing.html#typing.Any)] | [None](https://docs.python.org/3/builtins/constants.html#None) = None, random_seed: [int](https://docs.python.org/3/builtins/functions.html#int) = 1) → [Any](https://docs.python.org/3/library/typing.html#typing.Any)[[source]](https://github.com/adaptive-machine-learning/CapyMOA/blob/3e255b1/src/capymoa/base/_learner_params.py#L170)

Construct an instance from parameters produced by `get_params`.

#### get_input_schema() → [Schema](capymoa.stream.Schema.md#capymoa.stream.Schema) | [None](https://docs.python.org/3/builtins/constants.html#None)[[source]](https://github.com/adaptive-machine-learning/CapyMOA/blob/3e255b1/src/capymoa/stream/preprocessing/pipeline.py#L419)

Return the schema of instances entering the pipeline.

This is the schema of the first element that knows one, unless it was
given explicitly at construction.

#### get_params() → [dict](https://docs.python.org/3/builtins/stdtypes.html#dict)[[str](https://docs.python.org/3/builtins/stdtypes.html#str), [Any](https://docs.python.org/3/library/typing.html#typing.Any)][[source]](https://github.com/adaptive-machine-learning/CapyMOA/blob/3e255b1/src/capymoa/base/_learner_params.py#L163)

Return the hyper-parameters captured from the constructor.

#### get_schema() → [Schema](capymoa.stream.Schema.md#capymoa.stream.Schema) | [None](https://docs.python.org/3/builtins/constants.html#None)[[source]](https://github.com/adaptive-machine-learning/CapyMOA/blob/3e255b1/src/capymoa/stream/preprocessing/pipeline.py#L433)

Return the schema of instances leaving the pipeline.

This is the schema of the last element that knows one, so a pipeline
nested inside another reports what its own last element produces. Falls
back to the input schema when no element alters it, and is `None` for
an empty pipeline with no declared schema.

#### pass_forward(instance: [Instance](capymoa.core.Instance.md#capymoa.core.Instance)) → [Instance](capymoa.core.Instance.md#capymoa.core.Instance)[[source]](https://github.com/adaptive-machine-learning/CapyMOA/blob/3e255b1/src/capymoa/stream/preprocessing/pipeline.py#L542)

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](capymoa.core.Instance.md#capymoa.core.Instance), prediction: [Any](https://docs.python.org/3/library/typing.html#typing.Any) = None) → [tuple](https://docs.python.org/3/builtins/stdtypes.html#tuple)[[Instance](capymoa.core.Instance.md#capymoa.core.Instance), [Any](https://docs.python.org/3/library/typing.html#typing.Any)][[source]](https://github.com/adaptive-machine-learning/CapyMOA/blob/3e255b1/src/capymoa/stream/preprocessing/pipeline.py#L564)

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

#### predict(instance: [Instance](capymoa.core.Instance.md#capymoa.core.Instance)) → float64[[source]](https://github.com/adaptive-machine-learning/CapyMOA/blob/3e255b1/src/capymoa/stream/preprocessing/pipeline.py#L697)

The predict function of the regressor.
Calls pass_forward_predict internally and returns the prediction.

## Parameters

instance: Instance
: The instance to predict

## Returns

TargetValue
: The prediction of the pipeline

#### train(instance: [RegressionInstance](capymoa.core.RegressionInstance.md#capymoa.core.RegressionInstance))[[source]](https://github.com/adaptive-machine-learning/CapyMOA/blob/3e255b1/src/capymoa/stream/preprocessing/pipeline.py#L683)

The train function of the Regressor. Calls pass_forward internally.

## Parameters

instance: RegressionInstance
: The instance to train on

#### *property* schema *: [Schema](capymoa.stream.Schema.md#capymoa.stream.Schema) | [None](https://docs.python.org/3/builtins/constants.html#None)*

The schema of instances the pipeline consumes.

This is the *input* schema, because that is what
[`capymoa.base.Classifier`](capymoa.base.Classifier.md#capymoa.base.Classifier) and [`capymoa.base.Regressor`](capymoa.base.Regressor.md#capymoa.base.Regressor)
mean by `schema`: the instances handed to `train` and `predict`.
What the pipeline emits downstream may differ, and is reported by
[`get_schema()`](#capymoa.stream.preprocessing.RegressorPipeline.get_schema).

Defined as a property so that it keeps up with elements added after
construction.
