PythiloLesson 1 of 12 · progress kept in this browser

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])
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.