Determinism in an API means that the same relevant inputs produce the same output. Hidden inputs such as current time or random state can make predictions hard to reproduce. section 13.1
Expose output-affecting values such as time and random seeds as parameters when callers need reproducibility. Some algorithms, including text generation with temperature sampling, are nondeterministic by design. section 13.1
Listing 13.2 A better design for a predict function
def predict(features, time=None, seed=42):
if time is None:
time = datetime.now()
return model.predict(features, time, seed)
See how a predict function can accept time and seed as parameters. section 13.1









