Skip to content
ML Academy

Feature engineering and preprocessing · insight-1126

Test the serialization boundary where offline and online features meet for type and null coercion

Evidence type
practitioner heuristic
Difficulty
medium
Roles
ML engineer
Industries
cross-industry

Summary: situation, action, reason, boundary

  1. Situation

    Training features come from warehouse or parquet files while serving reads the same features through JSON, protobuf or a key-value store.

  2. Action

    Add a round-trip contract test: fetch a few thousand recent keys from the online path, compare each column with the offline value for dtype, null rate and value, and fail the release on any difference.

  3. Reason

    Each format has its own number and null semantics; a shared transformation function does not guarantee identical values after encoding and decoding.

  4. Boundary

    Any stack where the feature path differs between batch training and online inference.

Symptom or risk

Integers turn into floats, NaN becomes a null, a string or zero, timestamps lose their time zone and booleans become text, so the model scores values it never saw in training even though the logic is shared.

Exceptions

Batch-only scoring that reads the same files used in training.

Trade-offs

Needs online access in CI and a tolerance policy for floating-point rounding.

Pitfalls

Comparing means only, which hides a null that was replaced by a plausible default.

Lessons and concepts