STUDD#
- class capymoa.drift.detectors.STUDD[source]#
Bases:
BaseDriftDetector
STUDD: 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 = ADWIN(),
- 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(
- instance_x: ndarray | List[float] | Instance,
- teacher_prediction,
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.
- get_params()[source]#
Get the parameters of the drift detector.
- Returns:
Dictionary containing the detector parameters, including min_n_instances and information about the student and detector.
- Return type:
dict