CUSUM#

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

Bases: MOADriftDetector

CUSUM Drift Detector

Example usages:

>>> import numpy as np
>>> np.random.seed(0)
>>> from capymoa.drift.detectors import CUSUM
>>>
>>> detector = CUSUM(delta=0.005, lambda_=60)
>>>
>>> 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: 6 - at index: 1011
Change detected in data: 7 - at index: 1556
__init__(
min_n_instances: int = 30,
delta: float = 0.005,
lambda_: float = 50,
CLI: str | None = None,
)[source]#
Parameters:
  • moa_detector – The MOA detector object or class identifier.

  • CLI – The command-line interface (CLI) configuration for the MOA drift detector, defaults to None

CLI_help()[source]#
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.

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.

Parameters:

clean_history – Whether to reset detection history, defaults to False