# `EDDM`

### *class* capymoa.drift.detectors.EDDM[[source]](https://github.com/adaptive-machine-learning/CapyMOA/blob/3e255b1/src/capymoa/drift/detectors/eddm.py#L6)

Bases: [`MOADriftDetector`](capymoa.drift.base_detector.MOADriftDetector.md#capymoa.drift.base_detector.MOADriftDetector)

Early Drift Detection Method (EDDM) Drift Detector

EDDM monitors the distance between two consecutive errors. A drop in the average
distance between errors indicates drift.

EDDM complements DDM. DDM tracks the error rate. EDDM tracks how far apart
errors are. The two often disagree: EDDM is more stable on noisy streams,
DDM reacts faster when the error rate jumps.

The detector has no tuning parameters. MOA uses the fixed warning and drift
thresholds from the original paper.

## Example:

```pycon
>>> from capymoa.drift.detectors import EDDM
>>> detector = EDDM()
>>>
>>> data_stream = [0] * 1000 + [1] * 1000
>>>
>>> for i, x in enumerate(data_stream):
...     detector.add_element(x)
...     if detector.detected_change():
...         print('Change detected in data: ' + str(x) + ' - at index: ' + str(i))
Change detected in data: 1 - at index: 1030
```

## Reference:

Baena-García, M., del Campo-Ávila, J., Fidalgo, R., Bifet, A., Gavaldà, R., &
Morales-Bueno, R. (2006). Early drift detection method. Fourth International
Workshop on Knowledge Discovery from Data Streams, 6, 77-86.

#### \_\_init_\_()[[source]](https://github.com/adaptive-machine-learning/CapyMOA/blob/3e255b1/src/capymoa/drift/detectors/eddm.py#L44)

Create an EDDM drift detector.

EDDM has no hyper-parameters. MOA uses the thresholds from the original paper.

#### add_element(element: [float](https://docs.python.org/3/builtins/functions.html#float)) → [None](https://docs.python.org/3/builtins/constants.html#None)[[source]](https://github.com/adaptive-machine-learning/CapyMOA/blob/3e255b1/src/capymoa/drift/base_detector.py#L106)

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() → [str](https://docs.python.org/3/builtins/stdtypes.html#str)[[source]](https://github.com/adaptive-machine-learning/CapyMOA/blob/3e255b1/src/capymoa/drift/base_detector.py#L137)

#### detected_change() → [bool](https://docs.python.org/3/builtins/functions.html#bool)[[source]](https://github.com/adaptive-machine-learning/CapyMOA/blob/3e255b1/src/capymoa/drift/base_detector.py#L52)

Is the detector currently detecting a concept drift?

#### detected_warning() → [bool](https://docs.python.org/3/builtins/functions.html#bool)[[source]](https://github.com/adaptive-machine-learning/CapyMOA/blob/3e255b1/src/capymoa/drift/base_detector.py#L56)

Is the detector currently warning of an upcoming concept drift?

#### *classmethod* from_cli(cli: [str](https://docs.python.org/3/builtins/stdtypes.html#str)) → [MOADriftDetector](capymoa.drift.base_detector.MOADriftDetector.md#capymoa.drift.base_detector.MOADriftDetector)[[source]](https://github.com/adaptive-machine-learning/CapyMOA/blob/3e255b1/src/capymoa/drift/base_detector.py#L90)

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(schema: [Any](https://docs.python.org/3/library/typing.html#typing.Any) = None, params: [dict](https://docs.python.org/3/builtins/stdtypes.html#dict)[[str](https://docs.python.org/3/builtins/stdtypes.html#str), [Any](https://docs.python.org/3/library/typing.html#typing.Any)] | [None](https://docs.python.org/3/builtins/constants.html#None) = None, random_seed: [int](https://docs.python.org/3/builtins/functions.html#int) = 1) → [Any](https://docs.python.org/3/library/typing.html#typing.Any)[[source]](https://github.com/adaptive-machine-learning/CapyMOA/blob/3e255b1/src/capymoa/base/_learner_params.py#L170)

Construct an instance from parameters produced by `get_params`.

#### get_params() → [dict](https://docs.python.org/3/builtins/stdtypes.html#dict)[[str](https://docs.python.org/3/builtins/stdtypes.html#str), [Any](https://docs.python.org/3/library/typing.html#typing.Any)][[source]](https://github.com/adaptive-machine-learning/CapyMOA/blob/3e255b1/src/capymoa/base/_learner_params.py#L163)

Return the hyper-parameters captured from the constructor.

#### reset(clean_history: [bool](https://docs.python.org/3/builtins/functions.html#bool) = False) → [None](https://docs.python.org/3/builtins/constants.html#None)[[source]](https://github.com/adaptive-machine-learning/CapyMOA/blob/3e255b1/src/capymoa/drift/base_detector.py#L121)

Reset the drift detector.

* **Parameters:**
  **clean_history** – Whether to reset detection history, defaults to False

#### REQUIRES_FIT *: [bool](https://docs.python.org/3/builtins/functions.html#bool)* *= False*

If `True`, this detector needs a reference distribution before
it can detect change. Concept drift detectors leave this as
`False` and only use [`add_element()`](#capymoa.drift.detectors.EDDM.add_element).
