DriftMonitor<T>

Models & Types · AiDotNet.DriftDetection

A drift monitor that watches two lenses in a single pass and attributes drift to concept (the error stream) or covariate (the prediction-distribution) shift.

For Beginners

Prime the monitor on the training data (so it knows what “normal” looks like), then stream held-out or live (predicted, actual) pairs through Observe. Ask IsInDrift/Source at any time, or take a DriftReport from a batch check with Check.

How It Works

The configured IDriftDetector is the concept lens: it consumes the per-observation error |predicted - actual|, the industry-standard signal for “the model is getting wrong” (P(y|x) changed). Layered on top, in the same pass, is a lightweight windowed mean-shift test on the predictions themselves — the covariate lens — which flags “the inputs shifted” (P(x) changed) even before accuracy visibly degrades. Each observation updates both lenses once; there is no second full detector and no second pass.

Constructors

Constructor Summary
DriftMonitor(IDriftDetector<T> conceptDetector, int windowSize, double warningZ, double driftZ, int persistence, double errorSigma) Creates a drift monitor over a configured concept detector.

Properties

Property Summary
DriftSource Source { get; } Gets which shift the current drift is attributed to.
bool IsInDrift { get; } Gets whether either lens is currently in drift.
bool IsInWarning { get; } Gets whether either lens is currently in a warning state.

Methods

Method Summary
DriftReport Check(Vector<T> predicted, Vector<T> actual) Streams a whole (checking) batch through the monitor and returns an attributed report.
bool Observe(T predicted, T actual) Streams one observation through both lenses, updating drift/warning state.
void Prime(Vector<T> predicted, Vector<T> actual) Calibrates both lenses on a reference (training) stream: feeds the concept detector the training errors and accumulates the prediction reference distribution for the covariate lens.