Ahmed Doghri Logo Image
Ahmed Doghri

driftfilter

Deployment data moves while frozen classifiers stand still. driftfilter updates class prototypes forward-only and recovers 22.1 points, and with a velocity term it keeps up even when the drift runs four times faster.

driftfilter reproduced benchmark result

The World Moved. The Classifier Didn't

Most deployment drift isn't one dramatic domain jump. It arrives a little at a time until yesterday's decision boundary is quietly wrong.

driftfilter streams two classes through a gradual temporal shift. A frozen nearest-prototype classifier and an adaptive one see the exact same unlabeled sequence.

Adapt Forward, Without Backprop

The filtered model assigns each observation, then nudges the winning prototype toward it with a conservative exponential step. No labels, batches, gradients, or architecture changes. That keeps the tradeoff easy to inspect: adaptation can follow a moving population, and bad pseudo-labels can just as easily drag the wrong prototype along.

The Number

The frozen classifier finishes at 77.9% accuracy. Filtered prototypes reach 100%, a 22.1-point recovery under seeded gradual drift. It's a two-dimensional stress test, not a universal test-time-adaptation result.

A Perfect Score at One Drift Speed Is Not a General Result

The filter only tracked each prototype's position, moving it 8% toward every new point. That's fast enough at the published drift rate, which is why filtered accuracy hits a seed-invariant 100%. It's a real result, not a tautology, but it describes exactly one point on a curve.

Make the same linear drift about 4.4 times faster, still smooth and still a plausible deployment, and the position-only filter falls behind. It averages 68.6% across 40 tuning seeds and a disjoint 30-seed holdout, evaluated once, with one seed down at 61.7%. The frozen model averages 56.9% at that speed, so adaptation still helps, but it's chasing a target it can't keep up with.

The fix adds a velocity state. It predicts where each prototype will be before comparing it against a new point, then updates position and velocity from the observed displacement, which is the core idea of a Kalman filter and closer to what the cited research does. At the faster drift it holds 100% mean accuracy on both sweeps, and at the published rate it still reproduces the original 22.1-point number exactly.

One more honest result: when the classes drift toward each other instead of together, neither version beats frozen by much, because the frozen boundary already handles that symmetric case reasonably well. 10 tests pass on GitHub Actions across Python 3.9 through 3.13.

Research Basis

Inspired by TMLR's 2026 STAD paper. Every number on this page comes from this repository's own controlled benchmark, not from the paper.

Try It

Standard library only:

git clone https://github.com/ahmeddoghri/driftfilter && cd driftfilter
python driftfilter.py     # published drift: frozen 77.9%, filtered 100%
python eval_v2.py         # 4.4x faster drift: position-only 68.6%, with velocity 100%

Tools Used

Python
Test-Time Adaptation
Distribution Shift
Online Learning
Prototype Models
Kalman Filtering
unittest