RandomSearchClassifierPE#

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

Bases: ClassifierPipelineElement, Classifier

__init__(
classifier_class: Classifier,
hyperparameter_ranges: dict,
n_combinations: int,
rng: Generator,
)[source]#

Initializes the pipeline element with a classifier.

Parameters#

learner: Classifier

The classifier associated with this pipeline element.

classmethod from_params(
schema: Any = None,
params: dict[str, Any] | None = None,
random_seed: int = 1,
) → Any[source]#

Construct an instance from parameters produced by get_params.

get_input_schema() → Schema | None[source]#

Return the schema of instances this element expects to receive.

Defaults to get_schema(), which is correct for every element that does not alter the attribute set.

get_params() → dict[str, Any][source]#

Return the hyper-parameters captured from the constructor.

get_schema() → Schema | None[source]#

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

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

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,
prediction=None,
) → tuple[Instance, Any][source]#

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,
) → 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,
) → ndarray[tuple[Any, ...], dtype[float64]][source]#

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)[source]#

The train function of the Classifier. Calls pass_forward internally.

Parameters#

instance: LabeledInstance

The instance to train on

random_seed: int#

The random seed for reproducibility.

When implementing a classifier ensure random number generators are seeded.

schema: Schema#

The schema representing the instances.