ML Testing
A dedicated stack: data and feature tests, training smoke tests, model invariants, serving contracts, robustness — because a green unit test suite says nothing about a model.
Data tests, feature tests, training tests, model tests, serving tests, integration tests and drift tests — seven layers because a model can fail at every one of them while every unit test stays green.
Schema, nulls, ranges, cardinality, target prevalence and distribution against the training reference — and the one test that catches most leakage: no feature timestamp may exceed its prediction time.
On a tiny dataset, in CI, in minutes: the pipeline runs end to end, the loss goes down, an artifact appears, and the model can memorise a handful of examples. A pipeline that cannot overfit ten rows is broken, whatever the full run reports.
A probability is in [0, 1]. No output is NaN. A higher income does not lower a credit score. A change to an irrelevant field does not change the prediction. Invariants are the tests a model must pass regardless of its metric, and the ones a metric cannot express.
Request schema, preprocessing equivalence, model version, output schema, latency budget and fallback behaviour — the contract between the artifact and the request path, tested on every deploy, with a replay against the training path as the test that catches skew.
Missing features, extreme values, noise, rare segments and corrupted inputs — the test is not whether the model stays accurate under damage but whether it does what the design says it should: degrade gracefully, refuse, or fall back.
A challenger with a better aggregate metric can still lose the cases the champion passes. A regression test holds the challenger to the champion's slices and to a golden set of known hard examples — and the golden set is a leakage risk the moment anyone trains on it.