HDDMAverage#

class capymoa.drift.detectors.HDDMAverage[source]#

Bases: MOADriftDetector

Average Hoeffding’s bounds Drift Detector

Example usages:#

>>> import numpy as np
>>> from capymoa.drift.detectors import HDDMAverage
>>> np.random.seed(0)
>>>
>>> detector = HDDMAverage(drift_confidence=1e-10)
>>>
>>> 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
Change detected in data: 7 - at index: 1019
Change detected in data: 7 - at index: 1330

Reference:#

Frias-Blanco, Isvani, et al. “Online and non-parametric drift detection methods based on Hoeffding’s bounds.” IEEE Transactions on Knowledge and Data Engineering 27.3 (2014): 810-823.

__init__(
drift_confidence: float = 0.001,
warning_confidence: float = 0.005,
test_type: Literal['Two-sided', 'One-sided'] = 'Two-sided',
CLI: str | None = None,
)[source]#
Parameters:
  • drift_confidence – Significance level for drift detection (p-value threshold).

  • warning_confidence – Significance level for warning detection (p-value threshold).

  • test_type

    The type of statistical hypothesis test to use.

    • "Two-sided" detects drift in both directions, i.e. both increases and decreases in the monitored average. Use this when the direction of change is unknown.

    • "One-sided" only detects increases in the monitored average (i.e. performance degradation). Use this when only positive drift is relevant.

  • CLI – (Advanced) Override the CLI arguments passed directly to the underlying MOA detector, bypassing all other parameters.

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.

cli_help()[source]#
detected_change() bool[source]#

Is the detector currently detecting a concept drift?

detected_warning() bool[source]#

Is the detector currently warning of an upcoming concept drift?

get_params() Dict[str, Any][source]#

Get the hyper-parameters of the drift detector.

reset(clean_history: bool = False) None[source]#

Reset the drift detector. :param clean_history: Whether to reset detection history, defaults to False

TEST_TYPES = ['Two-sided', 'One-sided']#