GeometricMovingAverage#
- class capymoa.drift.detectors.GeometricMovingAverage[source]#
Bases:
MOADriftDetectorGeometric Moving Average Test Drift Detector
Example:#
>>> import numpy as np >>> from capymoa.drift.detectors import GeometricMovingAverage >>> np.random.seed(0) >>> >>> detector = GeometricMovingAverage() >>> >>> 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: 4 - at index: 1023
- __init__( )[source]#
Create a Geometric Moving Average drift detector.
- Parameters:
min_n_instances – Minimum number of instances to observe before change detection is enabled. Defaults to 30.
lambda – Detection threshold for the geometric moving-average statistic; higher values require stronger evidence before reporting change. Defaults to 1.0.
alpha – Smoothing factor for the geometric moving-average statistic. Values closer to 1.0 emphasise past observations and react more slowly to recent changes. Defaults to 0.99.
- 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,
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().