FeatureImportanceClassifier#

class capymoa.feature_selection.FeatureImportanceClassifier[source]#

Bases: Classifier

Base class for classifiers that expose feature-importance estimates.

Subclass this when implementing a pure Python feature-importance method. MOA-backed learners should use MOAFeatureImportanceClassifier.

__init__(
schema: Schema | None = None,
random_seed: int = 1,
window_size: int | None = None,
)[source]#
get_feature_importances(
normalize: bool = True,
) list[float][source]#

Return the current feature importance scores.

get_top_k_features(
k: int,
normalize: bool = True,
) list[int][source]#
get_windowed_feature_importances() list[dict[str, Any]] | None[source]#
predict(instance: Instance) int | None[source]#

Predict the label of an instance.

The base implementation calls predict_proba() and returns the label with the highest probability.

Parameters:

instance – The instance to predict the label for.

Returns:

The predicted label or None if the classifier is unable to make a prediction.

abstract predict_proba(
instance: Instance,
) ndarray[tuple[Any, ...], dtype[float64]] | None[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.

abstract train(instance: LabeledInstance) None[source]#

Train the classifier with a labeled instance.

Parameters:

instance – The labeled instance to train the classifier with.

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.