Validate the serving feature contract
Training and serving must agree on both feature meaning and feature order. A dictionary with the right values in the wrong matrix columns can produce plausible but incorrect predictions. Validate the schema at the boundary and construct columns from the declared order.
This contract rejects missing, extra, boolean and nonfinite values. The model should not silently replace invalid inputs with zeros. Real schemas also need units, availability timestamps and categorical vocabularies. A numeric shape check is only one layer of a reproducible preprocessing contract.
schema=["age","count"]
row={"count":4,"age":20}
print([row[name] for name in schema])Review the design
The schema order is part of model identity. Version it with the preprocessing state and weights, and reject unsupported schema versions at serving rather than guessing a column mapping.
Your task
Implement feature_matrix(rows,schema). Require unique schema names and exact row keys; each value is int or float, not bool, and finite. Return float rows in schema order, without mutating input.
The explanation opens here once every check passes.