Skip to content

Drift detection

anywatch.drift contains detectors for changes in the inputs and for degradation of performance. Labels often arrive late, so input drift is an early warning while performance monitoring is the confirmation.

Data drift

Quantile drift

QuantileDriftDetector needs only a reference sample. For each chosen quantile of the reference it monitors the share of new observations below that quantile. Under no drift the share equals the reference share. Any change in location, scale or shape moves at least one share.

from anywatch.drift import QuantileDriftDetector

detector = QuantileDriftDetector(reference_ages, quantiles=(0.1, 0.25, 0.5, 0.75, 0.9))
alarms = detector.update(new_ages)

The probability of any false alarm at any time is at most alpha.

Mean shift

MeanShiftDetector tests the mean of a feature with known bounds, such as a model score in \([0, 1]\) or a pixel intensity.

Population stability index

population_stability_index is the descriptive index common in industry. It carries no error guarantee and is provided for comparison with existing dashboards.

Performance degradation

PerformanceDegradationDetector tests whether the mean of a per-case score (for example correctness) is below baseline - tolerance:

from anywatch.drift import PerformanceDegradationDetector

detector = PerformanceDegradationDetector(baseline=0.92, tolerance=0.02)
detector.update(correct)

Change detection

A test with a fixed error budget becomes slower to react after a long period of good performance. For open ended monitoring, ChangeDetector implements a mixture Shiryaev-Roberts (or CUSUM) e-detector. Instead of a false alarm probability it controls the average run length: the expected number of observations before a false alarm is at least arl.

from anywatch.drift import ChangeDetector

detector = ChangeDetector(pre_change_mean=0.93, arl=5000)
for alarm in detector.update(correct):
    print("change detected at", alarm.time)

After an alarm the detector restarts by default, so it can be left running.