# `RandomSearchClassifierPE`

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

Bases: [`ClassifierPipelineElement`](capymoa.stream.preprocessing.ClassifierPipelineElement.md#capymoa.stream.preprocessing.ClassifierPipelineElement), [`Classifier`](capymoa.base.Classifier.md#capymoa.base.Classifier)

#### \_\_init_\_(classifier_class: [Classifier](capymoa.base.Classifier.md#capymoa.base.Classifier), hyperparameter_ranges: [dict](https://docs.python.org/3/builtins/stdtypes.html#dict), n_combinations: [int](https://docs.python.org/3/builtins/functions.html#int), rng: [Generator](https://numpy.org/doc/stable/reference/random/generator.html#numpy.random.Generator))[[source]](https://github.com/adaptive-machine-learning/CapyMOA/blob/3e255b1/src/capymoa/stream/preprocessing/pipeline.py#L719)

Initializes the pipeline element with a classifier.

## Parameters

learner: Classifier
: The classifier associated with this pipeline element.

#### *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#L48)

Return the schema of instances this element expects to receive.

Defaults to [`get_schema()`](#capymoa.stream.preprocessing.RandomSearchClassifierPE.get_schema), which is correct for every element that
does not alter the attribute set.

#### 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#L120)

Return the schema the wrapped classifier expects; learners do not alter it.

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

Trains the learner on the provided instance; then returns the instance.

## Parameters

instance: Instance
: An instance to train the learner

## Returns

Instance
: The instance that was provided to the function

#### pass_forward_predict(instance: [Instance](capymoa.core.Instance.md#capymoa.core.Instance), prediction=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#L785)

Trains the learner on the provided instance; then returns the instance.

## Parameters

instance: Instance
: An instance to train the learner

prediction: Any
: Most likely None, but could be anything in principle

## Returns

Tuple[Instance, Any]
: The transformed instance and the prediction of the regressor

#### predict(instance: [Instance](capymoa.core.Instance.md#capymoa.core.Instance)) → [int](https://docs.python.org/3/builtins/functions.html#int) | [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#L824)

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](capymoa.core.Instance.md#capymoa.core.Instance)) → [ndarray](https://numpy.org/doc/stable/reference/generated/numpy.ndarray.html#numpy.ndarray)[[tuple](https://docs.python.org/3/builtins/stdtypes.html#tuple)[[Any](https://docs.python.org/3/library/typing.html#typing.Any), ...], [dtype](https://numpy.org/doc/stable/reference/generated/numpy.dtype.html#numpy.dtype)[float64]][[source]](https://github.com/adaptive-machine-learning/CapyMOA/blob/3e255b1/src/capymoa/stream/preprocessing/pipeline.py#L844)

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.

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

The train function of the Classifier. Calls pass_forward internally.

## Parameters

instance: LabeledInstance
: The instance to train on

#### random_seed *: [int](https://docs.python.org/3/builtins/functions.html#int)*

The random seed for reproducibility.

When implementing a classifier ensure random number generators are seeded.

#### schema *: [Schema](capymoa.stream.Schema.md#capymoa.stream.Schema)*

The schema representing the instances.
