liveBook · Manning

Determinism

As explained in Machine Learning System Design

Deterministic behavior is behavior in which the same relevant inputs and state produce the same output.

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

How Machine Learning System Design covers it

How deep it goes
Demonstrates random seeds and current time as output-affecting inputs through predict-function examples.
Examples
Uses prediction functions with implicit or parameterized time and seeds, and notes temperature-sampled text generation.
What you can do after
Apply it via API design by exposing time and random seeds when callers need reproducible predictions.
How it connects
Connects API design with reproducibility, random seeds, input data, and predictability.

Also explained in

Compare how 10 books explain determinism →

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.