STUDD#
- class capymoa.drift.detectors.STUDD[source]#
Bases:
BaseDriftDetectorSTUDD: Student-Teacher Unsupervised Drift Detection
STUDD is a concept drift detection method that uses a student-teacher approach. It trains a student model to mimic a teacher model’s predictions and monitors the agreement between them to detect concept drift in an unsupervised manner.
The detector works by: 1. Training a student model on the same data as the teacher 2. Monitoring the agreement between student and teacher predictions 3. Using a base drift detector (e.g., ADWIN) on the agreement signal
Example usage:
>>> from capymoa.drift.detectors import ADWIN >>> from capymoa.drift.detectors import STUDD >>> from capymoa.classifier import AdaptiveRandomForestClassifier as ARF >>> from capymoa.datasets import ElectricityTiny >>> >>> stream = ElectricityTiny() >>> >>> learner = ARF(schema=stream.get_schema()) >>> student = ARF(schema=stream.get_schema()) >>> >>> detector = STUDD(student=student, detector=ADWIN()) >>> >>> instances_processed = 0 >>> while stream.has_more_instances(): ... instance = stream.next_instance() ... ... prediction = learner.predict(instance) ... detector.add_element(instance, prediction) ... ... if detector.detected_change(): ... print(f'Change detected at index: {instances_processed}') ... ... instances_processed += 1
Reference:
Cerqueira, V., Gomes, H. M., Bifet, A., & Torgo, L. (2023). STUDD: A student–teacher method for unsupervised concept drift detection. Machine Learning, 112(11), 4351-4378.
- __init__(
- student: MOAClassifier,
- min_n_instances: int = 500,
- detector: MOADriftDetector | None = None,
- Parameters:
student – Student model that mimics the teacher’s predictions
min_n_instances – Minimum number of instances before monitoring drift
detector – Base drift detector to monitor agreement signal
- add_element( ) None[source]#
Update the drift detector with a new instance and teacher prediction.
- Parameters:
instance_x (Instance) – The instance to add to the drift detector.
teacher_prediction (Any) – The prediction made by the teacher model for this instance.
- classmethod from_params( ) Any[source]#
Construct an instance from parameters produced by
get_params.
- instance_from_arr(x, y)[source]#
Convert an instance and prediction to a LabeledInstance.
- Parameters:
x (Any) – The instance to convert.
y (Any) – The prediction made by the teacher model for this instance.
- Returns:
The converted LabeledInstance.
- Return type:
- reset(clean_history: bool = False) None[source]#
Reset the drift detector.
- Parameters:
clean_history (bool) – Whether to reset detection history, defaults to False
- REQUIRES_FIT: bool = False#
If
True, this detector needs a reference distribution before it can detect change. Concept drift detectors leave this asFalseand only useadd_element().