MOAFeatureImportanceClassifier#

class capymoa.feature_selection.MOAFeatureImportanceClassifier[source]#

Bases: FeatureImportanceClassifier, MOAClassifier

MOA-backed feature-importance classifier.

Instantiate this class when the underlying learner is a MOA classifier. Pure Python implementations should subclass FeatureImportanceClassifier instead.

This wrapper is currently restricted to:

  • HoeffdingTree learners and subclasses, which are wrapped with FeatureImportanceHoeffdingTree

  • MOA ensembles built from HoeffdingTree learners, which are wrapped with FeatureImportanceHoeffdingTreeEnsemble

If MOA adds other feature-importance learner families in the future, they will not automatically work through this class. In that case this wrapper should be refactored to support those learners explicitly.

Accepted base_learner inputs: - CapyMOA MOAClassifier instance - CapyMOA MOAClassifier class - raw MOA learner instance - raw MOA learner class

__init__(
schema: Schema | None = None,
base_learner: Any = None,
random_seed: int = 1,
window_size: int | None = None,
)[source]#
cli_help()[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.

predict_proba(
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.

train(instance: Any) None[source]#

Train the classifier with a labeled instance.

Parameters:

instance – The labeled instance to train the classifier with.

feature_importances_per_window: list[dict[str, Any]] | None#
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.