liveBook · Manning

Invariant

As explained in Machine Learning System Design

The property of remaining unchanged under specified transformations or perturbations.

An invariant is a property that should remain unchanged under a specified transformation, perturbation, or model change. In ML products, invariants turn expectations such as “small input changes should not alter the decision” into measurable consistency requirements. section 5.2.1

Useful invariants depend on the system:

  • A vision model should usually preserve its output after minor lighting changes, while a sentiment model should tolerate replacing words with synonyms. section 5.2.1
  • A model should produce the same output for unchanged input, even across repeated executions or retraining with additional data or different seeds. section 5.2.1
  • Property-based tests can generate inputs and verify invariants such as transformation invariance, robustness to small perturbations, and monotonicity. section 10.5.1

Antifraud release check

If the same user is classified as fraudulent today, legitimate tomorrow, and fraudulent again next week without a meaningful input change, the system violates a practical invariant. Measuring consistency across model releases helps prevent unexpected downstream effects. section 5.2.1

Figure 5.5 New model releases are fairly consistent when estimating the probability (P) of the user (U) being fraudulent (F).
figure

Use the release-comparison figure to inspect how consistently successive models estimate fraud probability for the same user. section 5.2.1

How Machine Learning System Design covers it

How deep it goes
Defines transformation and retraining invariants, then connects them to consistency metrics and property-based tests without deriving implementation formulas.
Examples
Uses lighting, synonyms, image rotation, image scaling, audio volume, house size, and antifraud releases as test scenarios.
What it assumes
Assumes familiarity with model inputs and outputs while introducing perturbations, transformations, retraining changes, and expected model properties.
What you can do after
Diagnose/debug with it by defining expected perturbations and checking whether predictions remain stable through consistency metrics and generated tests.
How it connects
Connects invariants to consistency metrics, property-based testing, robustness, monotonicity, and ML system testing.

Also explained in

Compare how 12 books explain invariant →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Machine Learning System Design. The section links point to the parts of the book it draws on.