← Notes

MLOps learning notes: build, deploy, monitor, and roll back a model

Contents

A good notebook score answers one question about a prediction system. Can the next data batch run through it? Are production amounts expressed in the same units? Which model and threshold handled this request? Can the previous release be restored? MLOps turns these questions into recorded, testable operating procedures.

This guide starts with a small risk-prediction system, includes a downloadable local lab, and then develops the production decisions around it. All lab data are synthetic. Illustrative latency targets, costs, traffic, and business assumptions are labeled separately from measured lab results. The exercise does not estimate real fraud risk or clinical performance. References and version notes were checked on November 18, 2026.

Choose a reading route

You should be comfortable writing Python functions, using a terminal and virtual environment, and distinguishing features, labels, training data, and test data. If those concepts are new, work through classification, overfitting, and evaluation in the Google Machine Learning Crash Course first. No GPU, cloud account, Kubernetes, or distributed-training knowledge is required here.

Your starting pointSuggested routeWhat to produce
New to MLOpsConcepts → data and time → lineage → evaluation → labExplain what one prediction depends on and restore a model version.
Already training modelsStart at local setup, then study serving, tests, releases, and monitoringAllow roughly 60–90 minutes after installation for the main exercise. This is a study estimate.
Working on a projectData contracts → releases → monitoring → applications → troubleshootingA release checklist, alert response, and explicit rollback boundary.
Planning structured studyFinish the lab, then follow the six-stage routeOne inspectable artifact at each stage.

Build one complete small system, then add tools when a specific problem justifies them. The learning sequence and checklists below are teaching designs, not universal standards.

1. Operate the prediction system, including its changing dependencies

Imagine a payment-risk service. Before authorization, it receives an amount, account age, recent attempt count, and channel. It estimates risk, and a separate rule decides whether the payment enters review. Review capacity is limited, outcomes arrive later, the service has a response deadline, and future releases may change the model or threshold.

Application code is one source of behavior. Training data, feature definitions, label policies, fitted parameters, and thresholds are others. An upstream switch from dollars to cents can break predictions without changing the inference code. Versioning and validation must cover those dependencies.

Figure 1: The top row is the delivery path. The lower path represents operational feedback. An alert starts an investigation before anyone decides to retrain or change the system.

Google’s reference architecture describes levels 0, 1, and 2 as manual operation, automated ML pipelines, and CI/CD for pipelines. This is an explanatory maturity model, last reviewed August 28, 2024, rather than a requirement to install every component in its diagram.Google MLOps architecture

CI, CD, and CT change different things

TermResponsibilityExample output
Continuous Integration, CICheck implementation changes and relevant contracts before integrationTested feature code and a small pipeline smoke test.
Continuous Delivery / Deployment, CDPrepare or release an identified implementation, runtime, and model packageA release that can be inspected and restored.
Continuous Training, CTRepeat training when its trigger is satisfiedA candidate with evaluation evidence, awaiting release gates.

Continuous means repeatable automation. It does not mean training must run without interruption or every completed run must replace production. Manual approval can remain while the surrounding work becomes automated.

2. Attach the vocabulary to actual objects

TermMeaningIn this lab
Feature / labelPrediction-time input / outcome to predictFour input fields / a synthetic risk outcome.
RunOne execution with inputs, configuration, and resultsA training run named baseline.
ExperimentRelated runs addressing a questionComparing regularization settings.
ArtifactA produced file worth retainingModel, manifest, or evaluation report.
PipelineOrdered processing stepsScaling, encoding, classification; the term can also mean the whole training workflow.
LineageWhich inputs and processes produced an outputData, source, and environment → run → release.
RegistryA place that organizes versions and release referencesA teaching JSON alias file.
Training-serving skewDifferences in feature computation or input distributions between training and servingDollars in training, cents at serving.
SLI / SLOA measured service indicator / its chosen targetValid response ratio / a target for that ratio.

A training pipeline may read labels and fit transformations. An inference pipeline loads already-fitted transformations and predicts on new inputs. Fitting a new encoder inside a prediction request changes the meaning of its features.

3. Define the decision before the model

Write a one-page decision description: who needs the result, at what moment, what action follows, what errors cost, when the result becomes useless, and what happens on failure. Keep a rule or simple model as a baseline so that extra complexity has a comparison point.Google Rules of ML

All numbers in this table are illustrative business assumptions.

RequirementExampleDesign consequence
Prediction opportunityBefore each payment authorizationUse information available before that decision.
Output and actionProbability, followed by a review thresholdVersion the decision rule separately from the score.
Response budgetValid gateway response within 250 msInclude queueing, features, network, and serialization.
Review capacityAt most 500 cases per dayHigher recall cannot assume unlimited reviewers.
Failure pathA previously approved fallback ruleBusiness risk determines whether to allow, deny, or defer.
Success evidenceMature-label quality, loss, false declines, review volumeOffline metrics alone do not establish useful outcomes.

A model can improve recall while overwhelming reviewers. Keep optimization objectives, predictive metrics, service targets, and business outcomes distinct in the release report.

4. A data contract includes units and meaning

A row represents one prediction opportunity. Training ingestion and API validation use the same four-field contract.

FieldAccepted valuesMeaning
amountFinite number, 0–100,000US dollars.
account_age_daysFinite number, 0–36,500Account age at prediction, in days.
attempts_1hInteger, 0–1,000Known attempts in the preceding hour.
channelweb, mobile, or storeFixed teaching categories.

A numeric JSON schema cannot detect a dollar-to-cent conversion. Document missing-value policy, time zone, window boundaries, duplicate handling, acceptable delay, and the upstream owner. A fixed example can test both feature values and prediction behavior.

The lab rejects unknown categories, numeric strings, extra fields, and non-finite values. A real application can explicitly map unfamiliar categories to unknown, provided training and serving agree and the rate is monitored. Silently dropping unexpected columns makes upstream changes harder to investigate.

5. Prevent leakage by asking what was known then

Data leakage occurs when model development uses information unavailable at prediction time. Split before fitting scaling, imputation, feature selection, or similar transformations. A sklearn Pipeline helps keep fitting inside the training boundary; it cannot repair a feature calculated from the future.scikit-learn common pitfalls

Figure 2: A past event can still be unavailable at the decision. Chronological splitting also needs label-readiness checks and, where relevant, entity separation.

Distinguish event time, when something happened; available time, when the system could read it; and label maturity time, when observation is complete enough for evaluation. An event at 09:55 that arrives at 10:05 cannot support a reconstructed 10:00 decision. An outcome not yet observed is not automatically negative.

Match the split to its intended use

Intended generalizationStarting splitRemaining checks
Similar new samplesRandom splitDuplicates, repeated entities, preprocessing leakage.
A later periodChronological or rolling evaluationLabel maturity, availability, seasonality.
New patients or customersGroup-disjoint splitRepeated scans or events stay together.
New sites or devicesHeld-out site or external evaluationRepresentativeness and acquisition conditions.

GroupKFold separates groups; TimeSeriesSplit constructs future-facing windows. Neither automatically handles all grouping, time, delayed-label, and representation requirements.scikit-learn cross-validation

The lab uses chronological 60% / 20% / 20% splits, purging training and validation rows whose labels are not ready at the next boundary. Its two-hour label delay is a generator rule, not a general fraud-industry delay.

Check availability with a few rows

For a separate synthetic application submitted at time t, consider reported income at submission, income corrected after review, trailing behavior counts, and today’s customer status. The first is a candidate input; the correction is future information; trailing counts require a correct window and arrival time; today’s status needs historical versions.

Write an earliest-available time for every field. Then trace five evaluation rows back to their raw records. Confirm that each input existed at the corresponding decision. This small audit can expose retrospective corrections and query mistakes that training code alone does not reveal.

6. Reproducibility begins with the whole dependency chain

A model file or screenshot cannot identify a release completely. Connect fitted preprocessing, model, input contract, threshold, and evaluation evidence. This also defines what must be restored together.

Figure 3: The bundle includes preprocessing, parameters, contracts, thresholds, and evaluation identity. Record the resolved version because champion can move.

The following is an illustrative manifest design, not the lab’s exact JSON format:

run_id: baseline
data:
  snapshot: reference.csv
  sha256: "..."
  split: chronological-60-20-20
  label_delay_hours: 2
implementation:
  git_commit: "..."
  entrypoint: lab.py
  configuration: {C: 1.0, seed: 42}
environment:
  python: "3.12.x"
  dependency_lock: requirements.lock
prediction:
  pipeline_sha256: "..."
  schema_version: "risk-v1"
  threshold: "selected on validation, then frozen"
evaluation:
  report: evaluations/baseline.json
  metric: average_precision_score

Provenance means knowing where an artifact came from. Rerunnability means the procedure executes again. Reproducibility means results match within a defined tolerance. Bitwise equality is stronger. A seed helps, but does not guarantee equality across framework versions, platforms, or CPU/GPU execution.PyTorch reproducibility

A dataset name or digest is not a data backup. Start with retained, non-overwritten files and checksums. DVC becomes useful when large changing data must move with Git-based work: Git stores pointers, while cache and remote storage hold the data. Pushing Git does not push those objects.DVC getting started

7. Evaluate ranking, decisions, and probabilities separately

A classifier estimates a score; a threshold turns it into an action. Select the threshold on validation data, freeze it, and reserve final test data for evidence independent of that selection.scikit-learn threshold tuning

QuestionUseful measuresCommon mistake
Are positives ranked higher?ROC-AUC, Average Precision (AP)Good ranking does not select an operating threshold.
What happens at this threshold?Precision, recall, confusion matrix, alert volumeAccuracy can hide missed positives.
Are probabilities meaningful?Brier score, calibration plotsRanking can stay unchanged while probabilities miscalibrate.
Which groups struggle?Channel, site, or other relevant slicesSmall slices need counts and uncertainty.
Is the action useful?Cost, capacity, user outcomesOffline association does not prove intervention benefit.

Precision = TP / (TP + FP), and recall = TP / (TP + FN). TP is a correctly identified positive, FP a false alert, and FN a missed positive.

This lab reports AP from average_precision_score, which weights precision by recall increments. Trapezoidal integration of a precision-recall curve is a different calculation. Name the computation rather than treating every “PR-AUC” as interchangeable. Also distinguish metrics requiring scores from those requiring hard predictions.scikit-learn model evaluation

State the positive class, population, window, sample count, label coverage, and threshold. A score without those conditions is difficult to compare. See precision and recall and ROC-AUC versus PR-AUC.

Explain a threshold using a decision table

These are invented numbers, separate from the lab: 1,000 cases, including 50 positives; each miss costs $10 and each false review costs $1.

RuleTP / FP / FN / TNPrecision / recallReviewsAssumed cost
Higher threshold30 / 20 / 20 / 9300.60 / 0.6050$220
Lower threshold40 / 80 / 10 / 8700.333 / 0.80120$180

The lower threshold reduces assumed cost, but fails a capacity limit of 50 reviews. Actual costs may depend on amount, user, and intervention. Write the assumptions before comparing rules.

Calibration asks another question: among 100 cases assigned probabilities near 0.8, are roughly 80 positive? That is an illustration, not a guarantee for an individual. Calibration bins and slices need sufficient data; report their counts.

8. Run the local system first

Download the complete MLOps risk lab ZIP, extract it, and enter mlops-risk-lab. You need Python 3.12, a CPU, and local storage. Installation needs internet access; execution needs no account or external dataset.

cd mlops-risk-lab
python3.12 -m venv .venv
source .venv/bin/activate
python -m pip install -r requirements.txt

python lab.py generate
python lab.py train --run-id baseline
python lab.py evaluate --run-id baseline
python lab.py promote --run-id baseline
python lab.py predict --json '{"amount":120.0,"account_age_days":90.0,"attempts_1h":2,"channel":"web"}'
python -m pytest -q

In Windows PowerShell, create the environment with py -3.12 -m venv .venv and activate it using .\.venv\Scripts\Activate.ps1. Calling the environment’s Python directly is another option when activation policy prevents scripts.

The measured environment was macOS arm64, Python 3.12.16. Main pins are sklearn 1.7.2, pandas 2.3.3, NumPy 2.3.4, SciPy 1.16.3, FastAPI 0.121.1, Uvicorn 0.38.0, and pytest 8.4.2. The lock pins transitive versions, not installation artifact hashes. These are tested versions, not claims about the newest releases. Linux and Windows execution was not verified.

Outputs default to workspace/. Put the global option before each subcommand to use another root: python lab.py --root workspace-two generate. Keep that root consistent for all later commands.

9. Inspect artifacts, then release a second candidate

CommandResponsibility
generateCreate reference and shifted synthetic data with event and label-availability metadata.
trainFit preprocessing and classifier, choose a validation threshold, save a run bundle.
evaluateProduce fixed evaluation evidence and a release-gate result.
promotePoint production at a specific passing bundle.
predictReturn probability, threshold, version, and bundle digest.
monitorCompare inputs, scores, and mature-label quality.
rollbackRestore the recorded previous release.
workspace/
  data/reference.csv
  data/shifted.csv
  runs/baseline/
    model.joblib
    manifest.json
    environment.json
    lab.py
    api.py
    requirements.lock
  evaluations/baseline.json
  registry/production.json
  reports/monitor-....json

Offline prediction and the API load the same fitted sklearn Pipeline. Commands refuse to overwrite runs and evaluation reports. This is a program convention, not enforced immutable storage. SHA-256 detects content changes; it does not authenticate a publisher.

The JSON registry assumes one trusted writer. It has no multi-writer coordination, permissions, approval system, or durable release history. Evaluation verifies data and split identity, including test ID hashes and counts: hashing the dataset alone would not freeze a changed split policy.

The training core can be reduced to the following. The complete program additionally validates data, constructs historical splits, chooses the threshold, and writes evidence.

from sklearn.compose import ColumnTransformer
from sklearn.linear_model import LogisticRegression
from sklearn.pipeline import Pipeline
from sklearn.preprocessing import OneHotEncoder, StandardScaler

features = ["amount", "account_age_days", "attempts_1h", "channel"]
preprocess = ColumnTransformer([
    ("numeric", StandardScaler(), features[:3]),
    ("categorical", OneHotEncoder(handle_unknown="error"), ["channel"]),
])
pipeline = Pipeline([
    ("features", preprocess),
    ("classifier", LogisticRegression(C=1.0, max_iter=500, random_state=42)),
])
pipeline.fit(training[features], training["label"])
probabilities = pipeline.predict_proba(validation[features])[:, 1]

Here, training and validation are already-split DataFrames. Only training calls fit; later stages reuse the fitted object. Under this binary label convention, column 1 contains positive-class probabilities.

Measured reference results

These are rounded measurements from the locked lab, with synthetic positive prevalence near 20%.

MeasureBaseline
Training rows after label purge3,481
Validation rows after label purge1,081
Test rows1,200
Test prevalence0.1975
Validation-selected threshold0.20
Test AP0.435033
Test ROC-AUC0.756225
Precision / recall0.397403 / 0.645570
F1 / Brier score0.491961 / 0.136691
TN / FP / FN / TP731 / 232 / 84 / 153
Teaching release gatePass

The sample input returns probability about 0.311307, so flagged is true at threshold 0.20. Responses include model_version, bundle_sha256, threshold, and synthetic_only. Inspect your own files; numerical differences require checking dependencies, data, configuration, and splits before changing gates.

Promote and restore another version

python lab.py train --run-id candidate --C 0.2
python lab.py evaluate --run-id candidate
python lab.py promote --run-id candidate
python lab.py predict --json '{"amount":120.0,"account_age_days":90.0,"attempts_1h":2,"channel":"web"}'
python lab.py rollback
python lab.py predict --json '{"amount":120.0,"account_age_days":90.0,"attempts_1h":2,"channel":"web"}'

For logistic regression, smaller C means stronger regularization. The candidate selects threshold about 0.17. Its reference AP is 0.435109 and recall 0.704641, while F1 is 0.469101, below baseline’s 0.491961. This rehearses release mechanics, not overall superiority.

Both candidates inspect the same test set for this synthetic workflow exercise. They are not fresh independent final estimates at every iteration. Real selection belongs on validation or rolling evaluation, with an untouched final holdout. One report per run does not prevent test-based tuning across many runs.

Compare returned versions and digests after rollback. A running API retains its loaded model until restart.

To observe refusal:

python lab.py train --run-id blocked
python lab.py evaluate --run-id blocked --min-average-precision 0.999
python lab.py promote --run-id blocked

Promotion should exit 2. Evaluation exits 0 when report creation succeeds even if gate_passed is false; automation must inspect that field. Default AP ≥ 0.25, ROC-AUC ≥ 0.65, and recall ≥ 0.45 are teaching gates, without validated business meaning.

10. Tracking records experiments; a registry references versions

Tracking records runs, parameters, metrics, and artifacts. A Model Registry manages registered versions and release references. Recording an experiment does not activate its model.

The core exercise has no MLflow dependency. Add the optional tracking path with:

python -m pip install -r requirements-mlflow.txt
python lab.py train --run-id tracked --mlflow

The tested extras pin mlflow-skinny 3.6.0, SQLAlchemy 2.0.44, and Alembic 1.17.1, using an explicit SQLite URI. New local defaults changed to SQLite in MLflow 3.7.0; older tutorials and existing file stores can behave differently.MLflow self-hosting

Inspect local records without a server:

from pathlib import Path
from mlflow import MlflowClient

database = (Path("workspace") / "mlflow.db").resolve()
if not database.exists():
    raise FileNotFoundError("Train with --mlflow and check the output root")
client = MlflowClient(tracking_uri=f"sqlite:///{database}")
for experiment in client.search_experiments():
    runs = client.search_runs([experiment.experiment_id])
    print(experiment.name, [(run.info.run_id, run.data.metrics) for run in runs])

Keep the working directory and root consistent. Artifact copies live under workspace/mlartifacts/; a receipt links the local run to MLflow. Dataset metadata and digests do not archive every data byte. This client workflow includes no UI, server, or MLflow Model Registry.

For a later registry integration, models:/risk-model/7 identifies a version and models:/risk-model@champion resolves an alias. Reassigning an alias affects the next load, not an already-loaded object. Record the resolved identity. Model Stages have been deprecated since 2.9.0; use current alias workflows.MLflow Registry workflow

11. An API needs input, output, and loading contracts

After promotion, start the service:

python -m uvicorn api:app --host 127.0.0.1 --port 8000 --no-access-log

From another terminal in the same project and environment:

curl http://127.0.0.1:8000/healthz
curl http://127.0.0.1:8000/readyz
curl -X POST http://127.0.0.1:8000/predict -H 'Content-Type: application/json' -d '{"amount":120.0,"account_age_days":90.0,"attempts_1h":2,"channel":"web"}'

Liveness asks whether the process responds. Readiness asks whether a compatible active bundle has loaded. Prediction validates the request and uses that loaded object. None establishes predictive quality by itself.

FastAPI lifespan supports loading shared resources at startup, instead of reading the model on every request.FastAPI lifespan

Measured checks returned 200 for readiness and valid prediction, and 422 for a negative amount. Without an active bundle, liveness remains 200 while readiness and prediction return 503. After promotion or rollback, restart and check the concrete returned version.

For a custom root, start with MLOPS_LAB_ROOT=/tmp/risk-demo-2 python -m uvicorn api:app --host 127.0.0.1 --port 8000 --no-access-log. In PowerShell, set the variable using $env:MLOPS_LAB_ROOT.

Production also needs request-size limits, timeouts, authentication, concurrency policy, and logging rules. async def does not make CPU work automatically parallel. Workers generally have separate model memory; measure memory and throughput before increasing their count.

12. Organize tests by risk and cost

The following layers are a teaching recommendation. The original 2017 ML Test Score paper proposed 28 production-oriented testing and monitoring needs, supplementing ordinary software tests. Its score is not model accuracy or a certification.ML Test Score paper

LayerFailures to catchWhen
Fast code and contractsMissing fields, units, invalid categories, non-finite valuesEvery relevant change.
Small integrationTrain/save/load/predict failures and offline/API disagreementEvery pipeline change.
Candidate evaluationFailed quality gates, poor slices, excessive review volumeBefore promotion.
Deployment smoke testsMissing bundles, failed readiness, wrong versionEach deployment.
Operational checksStale inputs, latency, mature-label decline, broken recoveryContinuously or in scheduled drills.

Run python -m pytest -q. The measured core result was 21 passed, 1 skipped; the skipped test needs optional MLflow dependencies. With those installed, 22 passed.

Ask which mistake a test prevents. A file-existence test is weaker than a load-and-predict check. HTTP 200 is weaker than verified identity and prediction parity. Prioritize temporal boundaries, invalid inputs, serialization, feature consistency, and recovery rather than mechanical assertions to raise a coverage number. Deliberately break a contract once and confirm that its test fails.

13. Package the runtime and preserve delivery identity

Docker packages an application and runtime dependencies. It does not evaluate predictive quality or automatically supply scaling and operations. The download includes an optional, unbuilt and untested Dockerfile. It installs dependencies and copies named source files; training happens separately in the container environment.

These are extension commands for the reader to verify, not measured results:

docker build -t mlops-risk-lab .
docker run --rm -v risk-lab-demo:/app/workspace mlops-risk-lab python lab.py generate
docker run --rm -v risk-lab-demo:/app/workspace mlops-risk-lab python lab.py train --run-id baseline
docker run --rm -v risk-lab-demo:/app/workspace mlops-risk-lab python lab.py evaluate --run-id baseline
docker run --rm -v risk-lab-demo:/app/workspace mlops-risk-lab python lab.py promote --run-id baseline
docker run --rm -p 127.0.0.1:8000:8000 -v risk-lab-demo:/app/workspace mlops-risk-lab

Use a fresh volume name to repeat generation, and restart serving after alias changes. This image includes test dependencies and makes no production-hardening claim.

Copy dependency files before application code for caching and use exec-form CMD for signal handling. FastAPI’s container guide builds from a Python image; its old prebuilt FastAPI/Gunicorn base image is deprecated.FastAPI containers

CI should check an identified change and produce an identified package that deployment reuses. The download’s inactive ci.example.yml has not run on GitHub; its constituent local checks were executed. It explicitly checks gate_passed. Do not retrain casually on the deployment host and assume the result is the reviewed artifact.

Workflow artifacts and container-registry images are different objects. GitHub’s v4 workflow artifacts are immutable, but an automatic download digest mismatch currently produces a warning, not a hard failure. Enforce a failing comparison if integrity is a release gate.GitHub workflow artifacts

14. Choose serving patterns from decision timing

These patterns can coexist; they are not a maturity ranking.

PatternExampleOperational contract
Batch inferenceOvernight review listDeadline, completeness, freshness, safe reruns.
Synchronous APIA payment flow waits for a scoreEnd-to-end timeout, tail latency, fallback.
Asynchronous inferenceA large 3-D processing jobJob ID, queue age, retries, idempotency.
Event-stream inferenceContinuous transaction-window featuresEvent time, lateness, deduplication, state, lag.

Online serving does not imply online learning. A fixed model trained yesterday can answer each request. Event streaming is also different from LLM token streaming: one handles ongoing events and state; the other progressively returns one answer.

Retrying a prediction can repeat associated side effects. Use a durable idempotency key where work writes a payment, notification, or review action. Exactly-once stream guarantees have a defined boundary and do not automatically cover arbitrary external APIs.Kafka Streams concepts

15. Release through gates and restore a compatible whole

Offline improvement is one release condition. Check input compatibility, runtime, system performance, business limits, and recovery. Retain the predecessor and specify approval, expansion, and stop conditions before exposing traffic.

Figure 4: Passing offline checks and expanding live traffic are separate decisions. Shadow, canary, and A/B answer different questions; failure recovery restores the whole compatible release.
MethodDoes the candidate affect users?Main questionLimitation
ShadowIts response is ignoredCan it serve live-shaped requests, and how does it differ?No candidate treatment effect is observed merely by mirroring.
CanaryYes, for limited exposureIs expansion safe?Short windows can miss rare or delayed failures.
A/B experimentYes, by assignmentDoes a declared outcome improve?Routing weights alone do not establish valid causal evidence.

Shadow systems must suppress real side effects. Canary rollout keeps a recovery path when operational alarms fire. A/B evaluation also needs appropriate assignment, exposure records, duration, sample size, and guardrails.AWS shadow tests · AWS canary rollout · A/B testing notes

Write an SLO that can be evaluated

An illustrative target is: over 28 days, 99.5% of eligible requests return a valid gateway response within 250 ms. Define eligible, valid, timeout, and fallback treatment first. The SLI is the observed ratio; the SLO is its target. A ratio target’s error budget is one minus the target.Google SRE: implementing SLOs

p95 means approximately 95% of observed latencies fall at or below that value in the chosen window. Report traffic, input mix, warm/cold state, and errors. One timed request cannot establish sustainable QPS. Include queueing, features, preprocessing, execution, and the response path.

Rollback restores the compatible model, preprocessing, schema/features, threshold, and runtime. An alias cannot undo a destructive feature migration. After restoration, verify readiness, version, representative requests, and operating signals.

Measure capacity and cost within declared boundaries

As an extension, fix the input set and compare cold start, warm single-request behavior, sustained concurrency, and bursts. Record successes, errors, duration, successful-request latency percentiles, queue delay, and peak memory. No production QPS or latency claim is provided by this lab.

If feature retrieval dominates, more inference workers may not help. A growing queue can invalidate a short successful test. Locate the measured bottleneck before changing hardware or concurrency.

For illustrative arithmetic, $2 per hour divided across 40,000 usable results is $0.05 per 1,000. If only half finish usefully, that becomes $0.10. State whether idle capacity, feature queries, storage, network, retries, and shadow work are included.

16. Monitor five distinct layers

Figure 5: Moving downward generally requires more time before evidence is complete. Input changes and quality deterioration can occur independently.
LayerIndicatorsFirst question
SystemTraffic, errors, timeouts, percentiles, queue age, saturationCan users obtain timely usable results?
Data contractMissingness, ranges, categories, units, freshness, completenessDid upstream deliver the intended inputs?
Prediction behaviorScore distribution, positive/abstention rates, slicesDid model actions change?
Labeled qualityAP, recall, calibration, slices, coverage, maturityIs performance worse, and for whom?
Business and economicsLoss, false declines, review volume, completion, costIs the system achieving its purpose?

Latency, traffic, errors, and saturation are a useful starting point for service monitoring. Separate successful/error latency and inspect tails rather than relying on a mean.Google SRE monitoring

Record a stable prediction_id, prediction time, resolved model, threshold, and feature identity, then join later labels. Evaluate cohorts by prediction time and maturity, rather than treating labels arriving this week as this week’s model performance. Monitor join coverage: selectively available labels can bias results.

Under an invented seven-day policy, Monday’s predictions become mature next Monday. Friday’s unknown outcomes stay unknown. Separate recent service/input reports from mature-cohort quality and retain label versions when corrections arrive.

Each alert needs a window, threshold, owner, and first action. Unknown-category alerts should lead to source records and a decision about affected traffic.

The lab’s python lab.py monitor defaults to workspace/data/shifted.csv. The reference batch triggers data, score, and quality alerts; AP is about 0.194730 and ROC-AUC 0.359483. Aggregate heuristics are not formal drift hypothesis tests. The generator intentionally changes both inputs and their relationship to outcomes, so this demonstration does not show that input drift caused degradation.

Monitoring defaults to a fixed synthetic --as-of 2025-02-01T00:00:00Z. It normalizes UTC, excludes future events, and uses labels ready by that snapshot. Fewer than 100 mature rows, only one class, or missing labels produce an explicit unavailable status and null performance. Try python lab.py monitor --as-of 2025-01-10: one observed event and no mature labels cannot establish quality.

17. Drift is evidence for investigation

Terminology varies. Here, input drift means a change in P(X), concept change concerns P(Y|X), and prior change concerns P(Y). Input statistics cannot substitute for measured labeled performance.

Consider two mathematical constructions, with binary x and fixed model f(x)=x:

ChangeAccuracy
Keep y=x, change P(x=1) from 0.5 to 0.9Still 1 despite input drift.
Keep P(x), change the relationship to y=1-xFalls from 1 to 0 without input drift.

Input drift is therefore neither sufficient nor necessary for deterioration. PSI, KS, and distribution-distance thresholds need window, sample-size, seasonality, segment, and false-alarm policies.

Investigate instrumentation and freshness, then schema and pipeline incidents, then composition and mature labels. The response might be input repair, rollback, an approved rule change, candidate training, additional labeling, or observation. A holiday mix change and a cents/dollars bug require different actions.

18. Retraining produces a candidate; promotion is another decision

Triggers can include mature labels arriving, a schedule, investigated deterioration, or feature/label revisions. Record the trigger, snapshot, and evaluation population. An upstream column becoming empty should not automatically teach the model a supposed new reality.

Make the steps explicit: await inputs → validate → snapshot → train → evaluate → release checks → approve or reject → controlled deployment. Completed computation does not establish a useful candidate.

Before automation, rehearse interrupted training, rerunning a batch without duplicate release, and failed evaluation while the current model continues serving. Retain failed evidence so that the run history does not conceal rejected work.

19. Add orchestration and feature storage when their problems appear

An orchestrator helps when recurring jobs depend on several upstream tasks and need retries, backfills, deadlines, and execution records. Give each task inputs, outputs, idempotency rules, and failure behavior. Scheduling does not define correct labels or remove leakage. Compare Airflow and the dbt lab.

A feature store becomes useful when shared historical and online retrieval are difficult to keep consistent. A point-in-time join retrieves values valid for a historical prediction. A 10:00 sample must not use the latest 11:00 account total. Feast’s historical retrieval looks backward from each entity timestamp and applies a TTL.Feast point-in-time joins

Availability still matters. A 09:55 event arriving at 10:10 was unavailable at 10:00. Incorrect or overwritten timestamps cannot be repaired by adopting a tool. Define semantics, materialization freshness, and compatible rollback paths first.

20. Apply the lifecycle to different domains

Tabular fraud: feedback is delayed and selected

Fraud research describes rapid investigator feedback on selected alerts alongside broader delayed outcomes. Their selection processes differ.Dal Pozzolo et al., delayed supervised information

Separate recent review precision from mature-cohort quality. Record thresholds and capacity, define when an unconfirmed outcome becomes negative, and recognize that blocked transactions can hide counterfactual outcomes. The synthetic lab teaches mechanics without modeling that complete causal setting.

Imaging: preserve patient, acquisition, and preprocessing boundaries

A 3-D MRI segmentation research pipeline should identify sequences, orientation, spacing, resampling, intensity processing, cropping, label definitions, and postprocessing. Split by patient before distributing scans or slices. Add site, device, time, or external validation according to the intended question.

Operational checks include file integrity, dimensions, preprocessing failures, and queue-to-result time. Quality needs labeled cases and task-appropriate metrics. Voxel accuracy can hide poor small-structure segmentation; define Dice or surface measures, case aggregation, and reference-label quality. Use representativeness, independent testing, relevant conditions, and ongoing monitoring as design questions, then read the FDA introduction linking to the final 2025 IMDRF principles.FDA GMLP overview and IMDRF document

This is a research-pipeline example. It does not establish clinical suitability, intended-use validation, workflow integration, or change authorization.

LLMOps and RAG: version knowledge and prompts too

A RAG release includes the generator, prompt, parsing/chunking, embedding model, corpus/index snapshot, reranker, access policy, and evaluation set. Changing embedding spaces can require rebuilding a compatible index. Restoring only the prompt may not restore previous behavior.

Separate failures: parsing lost a table; retrieval chose the wrong source; truncation removed evidence; generation produced an unsupported answer. Tracing intermediate request steps helps locate these failures.MLflow tracing

Evaluate retrieval, source correctness and freshness, answer support, and task completion separately. Groundedness asks whether provided context supports the answer; it does not prove that context is true, current, or authorized. Calibrate LLM judges against human examples and record their configuration.MLflow RetrievalGroundedness

Monitor total usable-answer time, time to first token, errors/retries, tokens, cost, and sampled quality. Fast first tokens do not establish fast completion. Filter sensitive traces. The LangChain and LangGraph notes offer a related application route.

21. Make security constraints concrete

Load Python-serialized models only from trusted sources. pickle and joblib loading can execute code; a checksum identifies bytes but does not prove safety.scikit-learn model persistence Use controlled build sources and least-necessary runtime access.

Inputs, identifiers, prompts, retrieved documents, and labels can be sensitive. Avoid broad logging and artifact uploads. Prefer request IDs, versions, necessary aggregates, and authorized sanitized samples, with explicit access and retention policies.

Give CI tokens minimal permissions, prefer short-lived deployment identity, and keep secrets out of source. Treat privileged triggers and untrusted code carefully. Log redaction is not guaranteed; verify and pin workflow dependencies.GitHub Actions secure use

22. Diagnose the layer that evidence identifies

SymptomInspect firstLikely action
Good offline results, strange API outputSame-row fields, units, transforms, bundle identityRestore the shared fitted pipeline or fix the contract.
Readiness failsPromotion, root, artifact completenessEvaluate/promote, then correct paths and permissions.
Old version after promotionStartup time, returned version, aliasRestart or perform a controlled rollout.
Cross-machine score differencesDependencies, data, randomness, hardwareRestore the environment and state tolerances.
Drift alert, stable qualityMature labels, seasonality, slices, window sizeRecalibrate monitoring or observe.
Stable inputs, worse qualityLabel policy, conditional relationship, join coverageInvestigate concept or label changes.
Successful training, worsening productionGates, test reuse, thresholdsRepair evaluation and promotion policy.
Idle compute, slow resultsQueue, feature calls, serialization, retriesOptimize the measured bottleneck.
Successful batch, missing resultsInput manifest, row/key coverage, publicationAdd completeness and safe-commit checks.
Rollback still failsFeature/schema, preprocessing, threshold, runtimeRestore the compatible whole release.

Keep a short incident record: symptom, impact, evidence, cause, action, and the new check. The next reader should understand why the test exists.

23. Organize study around six deliverables

This is a flexible four-to-six-week study estimate, not a completion or employment promise. Combine stages if you know ML; stretch them if weekly time is limited.

StageFocusExit artifact
1. Data and model basicsLabels, baselines, splits, leakage, metricsA contract, split diagram, and AP/threshold explanation.
2. Repeatable local trainingCLI, lock, digests, pipelineA fresh-directory run and saved-model check.
3. Comparison and lineageCandidates, evaluation, trackingA versioned report with a selection rationale.
4. Inference and testsAPI or batch, validation, parityValid/invalid requests and a deliberately failing test.
5. Release and recoveryGates, versions, controlled rolloutPromotion and rollback with verified outputs.
6. Operations and extensionMonitoring, labels, scheduling, domain risksAn injected-incident report and your own design.

Then replace synthetic data with a suitably licensed public dataset while preserving a baseline and frozen evaluation. Choose one justified serving pattern and one actionable alert before adding cloud infrastructure or a cluster.

24. Choose resources by the exercise they enable

Public course material does not imply free cloud compute. Older lessons can teach useful design while their package APIs need adaptation. Choose the resource that addresses your current stage.

ResourceBest useExercise
Google ML Crash CourseClassification, overfitting, evaluationExplain a confusion matrix and train a baseline.
Google MLOps architectureImplementation delivery versus data-driven trainingDraw manual steps and approval points.
sklearn common pitfallsPreprocessing consistency and leakageRepair an all-data scaler fit.
ML Test ScoreProduction-oriented checks from the 2017 paperChoose three relevant checks and implement one.
DVC getting startedPointers, cache, remote storageRestore matching older data and code.
Made With MLConnected design, data, testing, productionTurn a notebook path into scripts and tests.
MLOps ZoomcampTracking, deployment, orchestration, monitoringReproduce one module, then change the dataset.
Full Stack Deep Learning 2022DL data, tests, and delivery tradeoffsPort a testing or deployment lab deliberately.
Stanford CS329SRequirements-led system designWrite a one-page design with failure tradeoffs.
Designing Machine Learning Systems, author’s pageData, retraining, and monitoring decisions; commercial bookReview your design using one chapter’s questions.

As checked on November 18, 2026, Zoomcamp is self-paced with no live cohort planned for 2026; historical certificate information is not a current certificate promise. FSDL is the 2022 course. Public CS329S material does not confer enrollment, credit, or a certificate.

For a final exercise, use a fresh directory, regenerate and train, submit an invalid request, promote and restore a version, identify the actual loaded bundle, and explain the shifted-batch alerts. Save the commands, outputs, and reasoning as your own experiment record.