# `DriftDetectionMetrics`

### *class* capymoa.drift.eval_detector.DriftDetectionMetrics[[source]](https://github.com/adaptive-machine-learning/CapyMOA/blob/3e255b1/src/capymoa/drift/eval_detector.py#L11)

Bases: [`object`](https://docs.python.org/3/builtins/functions.html#object)

Metrics for evaluating drift detection performance.

#### \_\_init_\_(fp: [int](https://docs.python.org/3/builtins/functions.html#int), tp: [int](https://docs.python.org/3/builtins/functions.html#int), fn: [int](https://docs.python.org/3/builtins/functions.html#int), precision: [float](https://docs.python.org/3/builtins/functions.html#float), recall: [float](https://docs.python.org/3/builtins/functions.html#float), episode_recall: [float](https://docs.python.org/3/builtins/functions.html#float), f1: [float](https://docs.python.org/3/builtins/functions.html#float), mdt: [float](https://docs.python.org/3/builtins/functions.html#float), ndt: [float](https://docs.python.org/3/builtins/functions.html#float), far: [float](https://docs.python.org/3/builtins/functions.html#float), ar: [float](https://docs.python.org/3/builtins/functions.html#float), n_episodes: [int](https://docs.python.org/3/builtins/functions.html#int), n_alarms: [int](https://docs.python.org/3/builtins/functions.html#int)) → [None](https://docs.python.org/3/builtins/constants.html#None)

#### ar *: [float](https://docs.python.org/3/builtins/functions.html#float)*

Alarm rate per [`EvaluateDriftDetector.rate_period`](capymoa.drift.eval_detector.EvaluateDriftDetector.md#capymoa.drift.eval_detector.EvaluateDriftDetector.rate_period) instances

#### episode_recall *: [float](https://docs.python.org/3/builtins/functions.html#float)*

Recall score for drift episodes (in this case, a correct prediction of a
drift episode is counted as 1 true positive).

#### f1 *: [float](https://docs.python.org/3/builtins/functions.html#float)*

F1 score (harmonic mean of precision and recall).

#### far *: [float](https://docs.python.org/3/builtins/functions.html#float)*

False alarm rate per [`EvaluateDriftDetector.rate_period`](capymoa.drift.eval_detector.EvaluateDriftDetector.md#capymoa.drift.eval_detector.EvaluateDriftDetector.rate_period) instances

#### fn *: [int](https://docs.python.org/3/builtins/functions.html#int)*

False negatives (missed drifts).

#### fp *: [int](https://docs.python.org/3/builtins/functions.html#int)*

False positives (incorrect detections).

#### mdt *: [float](https://docs.python.org/3/builtins/functions.html#float)*

Mean time to detect successful detections.

#### n_alarms *: [int](https://docs.python.org/3/builtins/functions.html#int)*

Total number of alarms raised

#### n_episodes *: [int](https://docs.python.org/3/builtins/functions.html#int)*

Total number of drift episodes

#### ndt *: [float](https://docs.python.org/3/builtins/functions.html#float)*

[`mdt`](#capymoa.drift.eval_detector.DriftDetectionMetrics.mdt) divided by [`EvaluateDriftDetector.max_delay`](capymoa.drift.eval_detector.EvaluateDriftDetector.md#capymoa.drift.eval_detector.EvaluateDriftDetector.max_delay), so that
detection delay is expressed as a fraction of the delay that was deemed acceptable.

For abrupt drifts this runs from 0 (detected the instant the drift began) to 1
(detected just as the drift became obvious anyway). It can fall outside that range
in two cases: with gradual drifts, because the delay is measured from the drift
start while detections stay valid until `end + max_delay`; and with
[`EvaluateDriftDetector.max_early_detection`](capymoa.drift.eval_detector.EvaluateDriftDetector.md#capymoa.drift.eval_detector.EvaluateDriftDetector.max_early_detection) above zero, which admits
detections before the drift and so negative delays.

Unlike [`mdt`](#capymoa.drift.eval_detector.DriftDetectionMetrics.mdt), which is a count of instances, `ndt` is comparable across
streams that were evaluated with different values of `max_delay`.

#### precision *: [float](https://docs.python.org/3/builtins/functions.html#float)*

Precision score `(tp / (tp + fp))`.

#### recall *: [float](https://docs.python.org/3/builtins/functions.html#float)*

Recall score `(tp / (tp + fn))`.

#### tp *: [int](https://docs.python.org/3/builtins/functions.html#int)*

True positives (correct detections).
