EWMAChart#
- class capymoa.drift.detectors.EWMAChart[source]#
Bases:
MOADriftDetectorEWMA Charts Drift Detector
Example:#
>>> import numpy as np >>> from capymoa.drift.detectors import EWMAChart >>> np.random.seed(0) >>> >>> detector = EWMAChart() >>> >>> data_stream = np.random.randint(2, size=2000) >>> for i in range(999, 2000): ... data_stream[i] = np.random.randint(4, high=8) >>> >>> for i in range(2000): ... detector.add_element(data_stream[i]) ... if detector.detected_change(): ... print('Change detected in data: ' + str(data_stream[i]) + ' - at index: ' + str(i)) Change detected in data: 5 - at index: 999
Reference:#
Ross, Gordon J., et al. “Exponentially weighted moving average charts for detecting concept drift.” Pattern recognition letters 33.2 (2012): 191-198.
- __init__(min_n_instances: int = 30, lambda_: float = 0.2)[source]#
Initialize the wrapped MOA drift detector.
- add_element(element: float) None[source]#
Update the drift detector with a new input value.
- Parameters:
element – A value to update the drift detector with. Usually, this is the prediction error of a model.
- classmethod from_cli(cli: str) MOADriftDetector[source]#
Create a detector instance configured from a MOA CLI string.
- Parameters:
cli – Command-line style options string for MOA detector hyper-parameters.
- Returns:
A new detector instance initialized with
cli.
- classmethod from_params( ) Any[source]#
Construct an instance from parameters produced by
get_params.
- reset(clean_history: bool = False) None[source]#
Reset the drift detector.
- Parameters:
clean_history – 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().