SLEADE#
- class capymoa.ssl.SLEADE[source]#
Bases:
MOAClassifierSSLSemi-supervised SLEADE ensemble.
SLEADE method handles partially labelled data and unsupervised drift detection.
>>> from capymoa.ssl import SLEADE >>> from capymoa.datasets import ElectricityTiny >>> from capymoa.evaluation import prequential_evaluation >>> >>> stream = ElectricityTiny() >>> clf = SLEADE(stream.get_schema()) >>> results = prequential_evaluation(stream, clf, max_instances=1000) >>> print(f"{results['cumulative'].accuracy():.1f}") 90.7
- __init__(
- schema: Schema | None = None,
- random_seed: int = 0,
- base_ensemble: str = 'StreamingRandomPatches',
- confidence_strategy: str = 'ArgMax',
- enable_random_threshold: bool = False,
- auto_weight_shrinkage: str = 'LabeledNoWarmupDivTotal',
- ssl_strategy: str = 'PseudoLabelCheckConfidence',
- ssl_min_confidence: float = 0.0,
- weight_function: str = 'ConfidenceWeightShrinkage',
- pairing_function: str = 'MajorityTrainsMinority',
- ssl_weight_shrinkage: float = 100.0,
- use_unsupervised_drift_detection: bool = False,
- student_learner_for_unsupervised_drift_detection: str = 'trees.HoeffdingTree -g 50 -c 0.01',
- drift_detection_method: str = 'ADWINChangeDetector -a 1.0E-5',
- unsupervised_detection_weight_window: int = 20,
- labeled_window_limit: int = 100,
Construct the SLEADE semi-supervised ensemble.
- Parameters:
schema – Stream schema.
random_seed – Random seed.
base_ensemble – Base ensemble learner (e.g., StreamingRandomPatches).
confidence_strategy – Confidence strategy (‘Sum’ or ‘ArgMax’).
enable_random_threshold – Use random min-confidence threshold.
auto_weight_shrinkage – Strategy for automatic weight shrinkage.
ssl_strategy – Semi-supervised learning strategy.
ssl_min_confidence – Minimum confidence to accept pseudo-label.
weight_function – Function for weighting pseudo-labelled instances.
pairing_function – Learner pairing function.
ssl_weight_shrinkage – Pseudo-label weight shrinkage value.
use_unsupervised_drift_detection – Whether to enable unsupervised drift detection.
student_learner_for_unsupervised_drift_detection – Student model for drift detection.
drift_detection_method – Drift detection algorithm and parameters.
unsupervised_detection_weight_window – Window size for unsupervised drift detection weighting.
labeled_window_limit – Maximum number of labelled instances in buffer.
- 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
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.