Gradient LabSign up free

Cheat sheets › Chapter 14

ML in practice cheat sheet

Ship models that keep working in the real world. Every lesson in one page: the key idea, the pseudocode and the terms.

Data pipelines

A data pipeline runs the same cleaning steps every time: drop duplicates, fix types, fill or remove missing values. Automated means it’s repeatable, rather than one person’s spreadsheet edits.

raw = collect(app logs, forms, sensors)
clean = remove duplicates, fix types, fill or drop missing values
check = validate(clean)            # e.g. ages must be between 0 and 120
features = build_features(clean)
store(features, version = "2026-11-25")    # reproducible

Terms: data pipeline, validation check

Experiment tracking

experiment tracking records, for every run, the settings, the data version, the results and the saved model. Tools do this automatically with a couple of lines of code.

for each training run:
    log settings: learning rate, layers, data version
    log results:  accuracy, loss curve, training time
    save the model file with an ID

compare runs side by side → pick the best and know why

Terms: experiment tracking

Deploying models

Training ends with a file full of weights. Nobody benefits until it’s put somewhere that can answer real requests. That’s deployment.

model = load("fraud-model-v7")

api = a web service:
    on request(transaction):
        score = model.predict(transaction)
        return score                    # answers in milliseconds

batch job: score all of yesterday's data overnight
on-device: a small model runs right on the phone

Terms: deployment, api

Monitoring and drift

A model learns from data collected at one point in time: here, the typical shopping basket. As long as new data looks similar, it does well.

every day:
    compare today's inputs with the training data
    track live accuracy as true answers arrive
    if they differ too much:
        alert the team → investigate → retrain on fresh data

Terms: drift

Fairness and responsible ML

A model can look accurate overall while treating groups of people very differently. fairness work starts by measuring approvals and mistakes separately for each group.

for each group (for example by age band or region):
    approval_rate = approvals / applicants
    error_rate    = mistakes / applicants
if the gaps are large:
    find the cause: unbalanced data? proxy features? biased labels?
    fix: better data, remove proxies, adjust thresholds, human review
keep measuring after launch

Terms: fairness, proxy

Revise with flashcards and quizzes. Free practice for every lesson in this chapter.

Open in the app