# `RDDM`

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

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

Reactive Drift Detection Method Drift Detector

## Example:

```pycon
>>> import numpy as np
>>> from capymoa.drift.detectors import RDDM
>>> np.random.seed(0)
>>>
>>> detector = RDDM()
>>>
>>> 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: 1003
```

## Reference:

Barros, R. S., Cabral, D. R., Gonçalves Jr, P. M., & Santos, S. G. (2017).
RDDM: Reactive drift detection method. Expert Systems with Applications, 90, 344-355.

#### \_\_init_\_(min_n_instances: [int](https://docs.python.org/3/builtins/functions.html#int) = 129, warning_level: [float](https://docs.python.org/3/builtins/functions.html#float) = 1.773, drift_level: [float](https://docs.python.org/3/builtins/functions.html#float) = 2.258, max_size_concept: [int](https://docs.python.org/3/builtins/functions.html#int) = 40000, min_size_concept: [int](https://docs.python.org/3/builtins/functions.html#int) = 7000, warning_limit: [int](https://docs.python.org/3/builtins/functions.html#int) = 1400)[[source]](https://github.com/adaptive-machine-learning/CapyMOA/blob/3e255b1/src/capymoa/drift/detectors/rddm.py#L38)

Create an RDDM drift detector.

* **Parameters:**
  * **min_n_instances** – Minimum number of instances before the detector starts
    monitoring for drift. Defaults to 129.
  * **warning_level** – Multiplier applied to the minimum error estimate for
    entering the warning zone. Defaults to 1.773.
  * **drift_level** – Multiplier applied to the minimum error estimate for
    declaring drift. Defaults to 2.258.
  * **max_size_concept** – Maximum number of instances allowed in a stable concept
    before forcing an RDDM reset when no warning is active. Defaults to 40000.
  * **min_size_concept** – Size of the internal prediction buffer and the minimum
    stable concept length retained for recovery after warnings. Defaults to
    7000.
  * **warning_limit** – Number of consecutive warning instances allowed before
    warning is promoted to drift. Defaults to 1400.

#### 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.RDDM.add_element).
