DynamicEnsembleMemberSelection#
- class capymoa.classifier.DynamicEnsembleMemberSelection[source]#
Bases:
MOAClassifierDynamic Ensemble Member Selection (DEMS).
Dynamic Ensemble Member Selection (DEMS) [1] dynamically selects a subset of ensemble members based on their estimated performance and tree-level information. Only SRP and ARF are included here because of the performance significance.
>>> from capymoa.classifier import DynamicEnsembleMemberSelection >>> from capymoa.datasets import ElectricityTiny >>> from capymoa.evaluation import prequential_evaluation >>> >>> stream = ElectricityTiny() >>> classifier = DynamicEnsembleMemberSelection(stream.get_schema()) >>> results = prequential_evaluation(stream, classifier, max_instances=1000) >>> print(f"{results.accuracy():.1f}") 90.6
- __init__(
- schema: Schema | None = None,
- random_seed: int = 0,
- ensemble_class: str = 'StreamingRandomPatches',
- base_learner: str = 'trees.HoeffdingTree -g 50 -c 0.01',
- tree_learner: str = 'ARFHoeffdingTree -e 2000000 -g 50 -c 0.01',
- ensemble_size: int = 100,
- max_features=0.6,
- training_method: str = 'RandomPatches',
- lambda_param: float = 6.0,
- number_of_jobs: int = 1,
- drift_detection_method: str = 'ADWINChangeDetector -a 1.0E-5',
- warning_detection_method: str = 'ADWINChangeDetector -a 1.0E-4',
- disable_weighted_vote: bool = False,
- disable_drift_detection: bool = False,
- disable_background_learner: bool = False,
- k_value: int = 5,
- disable_self_optimising: bool = False,
Dynamic Ensemble Member Selection (DEMS) Classifier.
- Parameters:
ensemble_class – which ensemble to use (“StreamingRandomPatches” or “AdaptiveRandomForest”).
base_learner – base classifier (used by SRP).
tree_learner – ARF tree learner (only used by ARF, cannot be changed).
ensemble_size – number of ensemble members.
max_features – subspace size configuration, similar to SRP: float in [0, 1]: percentage of features (e.g. 0.6 = 60%). int: exact number of features. “sqrt”: use sqrt(M)+1. None: default (60%).
training_method – “RandomSubspaces”, “Resampling”, or “RandomPatches” (SRP).
lambda_param – Poisson lambda for bagging.
number_of_jobs – number of parallel jobs for ARF (-1 = as many as possible).
drift_detection_method – MOA CLI string for drift detector.
warning_detection_method – MOA CLI string for warning detector.
disable_weighted_vote – if True, disables accuracy-weighted voting.
disable_drift_detection – if True, turns off drift detectors (and bkg learners).
disable_background_learner – if True, turns off background learners.
k_value – fixed K for DEMS when self-optimising is disabled.
disable_self_optimising – if True, use the fixed k_value instead of self-optimising.
- predict(
- instance: Instance,
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
Noneif the classifier is unable to make a prediction.
- predict_proba(
- instance,
Return probability estimates for each label.
- Parameters:
instance – The instance to estimate the probabilities for.
- Returns:
An array of probabilities for each label or
Noneif the classifier is unable to make a prediction.
- train(instance)[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.