Model Deployment Practical

A hands-on exercise for packaging, serving, testing, monitoring, and rolling back a classification model with Python

Author

Complex Data Insights

Published

Aug 2026

COMPLEX DATA INSIGHTS
CDI Practicals

Hands-on exercises and step-by-step tools for doing, applying, and building evidence.

Model Deployment Practical

A hands-on exercise for packaging, serving, testing, monitoring, and rolling back a classification model with Python

AuthorComplex Data Insights
PublishedAug 2026
ID CDI-DATASCIENCE-PRACTICAL-010
Type Practical Product
Audience Students, researchers, analysts, professionals, mentors, and learners developing practical data science skills
Theme Responsible deployment turns a validated model into a controlled, observable, reversible service with explicit contracts and evidence

How to Use This Practical

Work through the practical in order. Each stage produces an artifact needed by the next stage. Run the code in a clean environment, read the interpretation after each output, and adapt the contracts and decision rules to your own project.

This practical uses a small public dataset and a fitted scikit-learn pipeline so that the complete workflow can run locally. The objective is not to create a production medical device. It is to learn the engineering and governance habits that make deployment defensible.

If you are reading the rendered HTML, expand folded examples only when you need an implementation pattern. The main workflow contains everything required to complete the practical.

Practical Overview

A model is not deployed merely because it has been serialized. Deployment requires an explicit interface, reproducible packaging, controlled release, observable behavior, and a safe route back when assumptions fail.

In this practical you will turn a fitted binary-classification pipeline into a versioned release candidate. You will validate payloads, make local and batch predictions, generate a minimal API application, test success and failure paths, calculate operational and drift signals, rehearse rollback, and produce a deployment report.

The model predicts the demonstration target from numeric measurements in the scikit-learn breast-cancer dataset. The positive class used here is 1, corresponding to the dataset’s benign label. This choice is purely educational.

Learning exercise, not an operational clinical model

The dataset and outputs are used only to demonstrate deployment practice. Do not use this model for diagnosis, treatment, triage, or any decision affecting a person.

Learning Outcomes

By the end of this practical, you should be able to:

  • translate a model-use statement into deployment acceptance criteria;
  • define machine-readable input and output contracts;
  • package a complete preprocessing-and-model pipeline with metadata;
  • reject missing, extra, non-numeric, and implausible inputs;
  • implement deterministic local and batch prediction paths;
  • specify health and prediction endpoints for an API service;
  • test valid and invalid requests before release;
  • record privacy-conscious prediction events;
  • monitor service behavior, data quality, and population drift;
  • define alert, escalation, and rollback rules; and
  • assemble evidence for a release decision.

What You Will Produce

The completed workflow creates:

  • a deployment brief;
  • a versioned model bundle and checksum;
  • input and output schemas;
  • an example request and response;
  • a generated API application and dependency file;
  • contract-test results;
  • a batch prediction file;
  • privacy-conscious prediction logs;
  • service-level and drift-monitoring summaries;
  • a rollback rehearsal record;
  • a release manifest; and
  • a deployment report.
model-deployment-practical/
├── practical.qmd
├── _quarto.yml
├── assets/
│   └── css/
│       └── cdi-practical.css
├── artifacts/
│   ├── model-010-v1.joblib
│   ├── model-010-v1.metadata.json
│   └── release-manifest.json
├── config/
│   ├── input-schema.json
│   └── output-schema.json
├── service/
│   ├── app.py
│   └── requirements.txt
├── tests/
│   └── contract-test-results.csv
├── monitoring/
│   ├── reference-profile.csv
│   ├── prediction-events.jsonl
│   ├── service-window.csv
│   └── drift-summary.csv
├── outputs/
│   ├── example-request.json
│   ├── example-response.json
│   ├── batch-predictions.csv
│   └── rollback-rehearsal.json
└── reports/
    └── model-deployment-report.md

Tools and Requirements

This practical requires Python 3.10 or later, Quarto, and these Python packages:

python -m pip install -r requirements.txt

The rendered exercise executes only the core data-science dependencies. FastAPI and Uvicorn are included in the generated service requirements for learners who choose to launch the optional local API.

After creating the environment, the complete workflow can also be run outside Quarto. This is the recommended verification path before rendering because it also executes API-level success and failure tests:

bash scripts/bash/run-workflow.sh

The command generates evidence locally; it does not deploy a service or approve the release. See README.md for the full setup, inspection, rendering, and manual packaging sequence.

Relationship to Practical 009

Practical 009 focused on building and selecting a complete model pipeline. Practical 010 begins at the handoff between model development and operations.

In a real project, copy the approved pipeline, feature dictionary, selection record, validation results, and model card from the previous practical. Here, the first executable stage recreates a compact validated pipeline so the deployment workflow is fully reproducible and does not depend on files outside this repository.

The deployment team should not silently change features, preprocessing, thresholds, or class definitions. Any such change creates a new model candidate that must return to model validation.

Project Setup

Create the folders, import the libraries, and fix the random seed. The paths are relative to the practical root so the same code works when the repository is moved.

Show code
from pathlib import Path
from datetime import datetime, timezone
import hashlib
import json
import platform
import time

import joblib
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import sklearn
from IPython.display import Markdown, display
from sklearn.datasets import load_breast_cancer
from sklearn.impute import SimpleImputer
from sklearn.linear_model import LogisticRegression
from sklearn.metrics import roc_auc_score
from sklearn.model_selection import train_test_split
from sklearn.pipeline import Pipeline
from sklearn.preprocessing import StandardScaler

# Preserve complete text in rendered pandas tables. CSS below wraps long values.
pd.set_option("display.max_colwidth", None)

SEED = 2026
MODEL_ID = "model-010"
MODEL_VERSION = "v1"
RELEASE_ID = f"{MODEL_ID}-{MODEL_VERSION}"
DECISION_THRESHOLD = 0.50

ROOT = Path.cwd()
PATHS = {
    "artifacts": ROOT / "artifacts",
    "config": ROOT / "config",
    "service": ROOT / "service",
    "tests": ROOT / "tests",
    "monitoring": ROOT / "monitoring",
    "outputs": ROOT / "outputs",
    "reports": ROOT / "reports",
}
for path in PATHS.values():
    path.mkdir(parents=True, exist_ok=True)

print(f"Release candidate: {RELEASE_ID}")
print(f"Python: {platform.python_version()} | scikit-learn: {sklearn.__version__}")
Release candidate: model-010-v1
Python: 3.12.6 | scikit-learn: 1.9.0

Define the Deployment Brief

The deployment brief connects technical implementation to a bounded use case. It also turns vague expectations into release gates.

Show code
deployment_brief = {
    "release_id": RELEASE_ID,
    "owner": "Complex Data Insights learning team",
    "service_purpose": "Demonstrate controlled deployment of a binary classifier",
    "intended_users": ["learners", "reviewers", "technical mentors"],
    "permitted_use": "Education, portfolio evidence, and local technical testing",
    "prohibited_use": "Clinical or other real-world decisions affecting people",
    "prediction_mode": ["single request", "batch"],
    "positive_class": {"value": 1, "meaning": "benign in the source dataset"},
    "decision_threshold": DECISION_THRESHOLD,
    "release_gates": {
        "minimum_holdout_roc_auc": 0.95,
        "contract_tests_must_pass": True,
        "artifact_reload_must_match": True,
        "maximum_missing_rate": 0.05,
        "maximum_population_stability_index": 0.25,
    },
    "rollback_triggers": [
        "schema or prediction failure rate exceeds 5% in a review window",
        "p95 latency exceeds 250 ms in a review window",
        "PSI exceeds 0.25 for any required feature",
        "a critical safety, privacy, or integrity defect is confirmed",
    ],
}

brief_path = PATHS["config"] / "deployment-brief.json"
brief_path.write_text(json.dumps(deployment_brief, indent=2))
pd.DataFrame(
    [{"field": key, "value": json.dumps(value) if isinstance(value, (dict, list)) else value}
     for key, value in deployment_brief.items()]
).head(8)
field value
0 release_id model-010-v1
1 owner Complex Data Insights learning team
2 service_purpose Demonstrate controlled deployment of a binary classifier
3 intended_users ["learners", "reviewers", "technical mentors"]
4 permitted_use Education, portfolio evidence, and local technical testing
5 prohibited_use Clinical or other real-world decisions affecting people
6 prediction_mode ["single request", "batch"]
7 positive_class {"value": 1, "meaning": "benign in the source dataset"}

A release gate blocks promotion before deployment. A monitoring alert signals that a running release may need investigation or rollback. The same metric can have different thresholds for these two purposes, but both thresholds should be set before results are observed.

Prepare a Reproducible Model Handoff

Select a stable subset of numeric features, create a stratified holdout set, and fit a complete pipeline. The preprocessing objects remain inside the pipeline so inference applies exactly the same transformations as training.

Show code
dataset = load_breast_cancer(as_frame=True)
feature_names = [
    "mean radius",
    "mean texture",
    "mean perimeter",
    "mean area",
    "mean smoothness",
    "worst radius",
    "worst texture",
    "worst perimeter",
    "worst area",
    "worst concavity",
]

X = dataset.data.loc[:, feature_names].copy()
y = dataset.target.astype(int)
X_train, X_holdout, y_train, y_holdout = train_test_split(
    X, y, test_size=0.20, random_state=SEED, stratify=y
)

pipeline = Pipeline([
    ("imputer", SimpleImputer(strategy="median")),
    ("scaler", StandardScaler()),
    ("classifier", LogisticRegression(max_iter=2000, random_state=SEED)),
])
pipeline.fit(X_train, y_train)

holdout_probability = pipeline.predict_proba(X_holdout)[:, 1]
holdout_auc = roc_auc_score(y_holdout, holdout_probability)

handoff_summary = pd.DataFrame({
    "measure": ["training rows", "holdout rows", "required features", "holdout ROC AUC"],
    "value": [len(X_train), len(X_holdout), len(feature_names), round(holdout_auc, 4)],
})
handoff_summary
measure value
0 training rows 455.0000
1 holdout rows 114.0000
2 required features 10.0000
3 holdout ROC AUC 0.9944

The holdout score is a release-candidate check, not evidence of clinical validity. Deployment readiness also depends on contract, reliability, privacy, monitoring, and recovery evidence.

Define the Input and Output Contracts

What is a model contract?

A model contract is a set of rules for communicating with the model. It explains what information you must send and what the model promises to return.

Think of it like an order form:

  • The input contract specifies which boxes must be completed and what kind of information belongs in each box.
  • The output contract specifies what you receive after submitting a valid form.
  • An incomplete or invalid form is rejected before it reaches the model.
Valid request → accepted → prediction returned

Missing measurement → rejected
Text instead of a number → rejected
Unknown measurement → rejected
Implausible value → rejected

The contract helps the model and the system using it speak the same language. It catches input problems before they become unreliable predictions.

The input contract fixes feature names, types, nullability, and plausible demonstration ranges derived from the training data. Production ranges should come from domain knowledge and data-owner agreement, not automatically from observed extrema.

Show code
input_properties = {}
for feature in feature_names:
    input_properties[feature] = {
        "type": "number",
        "minimum": float(X_train[feature].min() * 0.5),
        "maximum": float(X_train[feature].max() * 1.5),
    }

input_schema = {
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "title": "Model010PredictionRequest",
    "type": "object",
    "additionalProperties": False,
    "required": feature_names,
    "properties": input_properties,
}
output_schema = {
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "title": "Model010PredictionResponse",
    "type": "object",
    "additionalProperties": False,
    "required": ["release_id", "prediction", "probability", "threshold"],
    "properties": {
        "release_id": {"type": "string"},
        "prediction": {"type": "integer", "enum": [0, 1]},
        "probability": {"type": "number", "minimum": 0, "maximum": 1},
        "threshold": {"type": "number", "minimum": 0, "maximum": 1},
    },
}

(PATHS["config"] / "input-schema.json").write_text(json.dumps(input_schema, indent=2))
(PATHS["config"] / "output-schema.json").write_text(json.dumps(output_schema, indent=2))

pd.DataFrame([
    {
        "feature": feature,
        "type": rules["type"],
        "minimum": round(rules["minimum"], 3),
        "maximum": round(rules["maximum"], 3),
        "required": feature in input_schema["required"],
    }
    for feature, rules in input_properties.items()
])
feature type minimum maximum required
0 mean radius number 3.490 42.165 True
1 mean texture number 5.190 58.920 True
2 mean perimeter number 21.895 282.750 True
3 mean area number 71.750 3751.500 True
4 mean smoothness number 0.026 0.217 True
5 worst radius number 3.965 54.060 True
6 worst texture number 6.435 74.310 True
7 worst perimeter number 25.205 376.800 True
8 worst area number 92.600 6381.000 True
9 worst concavity number 0.000 1.878 True

Package and Fingerprint the Release Candidate

Save the fitted pipeline and metadata separately. A SHA-256 checksum detects accidental or unauthorized artifact changes; it does not replace access control or signed releases.

Show code
artifact_path = PATHS["artifacts"] / f"{RELEASE_ID}.joblib"
metadata_path = PATHS["artifacts"] / f"{RELEASE_ID}.metadata.json"
joblib.dump(pipeline, artifact_path)

artifact_sha256 = hashlib.sha256(artifact_path.read_bytes()).hexdigest()
metadata = {
    "model_id": MODEL_ID,
    "version": MODEL_VERSION,
    "release_id": RELEASE_ID,
    "created_at_utc": datetime.now(timezone.utc).isoformat(),
    "framework": "scikit-learn",
    "framework_version": sklearn.__version__,
    "artifact_file": artifact_path.name,
    "artifact_sha256": artifact_sha256,
    "features": feature_names,
    "positive_class": 1,
    "threshold": DECISION_THRESHOLD,
    "validation": {
        "dataset": "sklearn breast cancer demonstration data",
        "holdout_rows": int(len(X_holdout)),
        "holdout_roc_auc": round(float(holdout_auc), 6),
        "random_seed": SEED,
    },
}
metadata_path.write_text(json.dumps(metadata, indent=2))

pd.DataFrame({
    "property": ["artifact", "size_bytes", "sha256", "holdout_roc_auc"],
    "value": [artifact_path.name, artifact_path.stat().st_size, artifact_sha256, round(holdout_auc, 4)],
})
property value
0 artifact model-010-v1.joblib
1 size_bytes 2417
2 sha256 7a3ac892ec884570e8e993c02d3e4212e2f58b159f93bb2fb4e8fed418eb9719
3 holdout_roc_auc 0.9944

Verify Artifact Integrity and Reproducibility

Reload the artifact in a fresh object, verify its checksum, and confirm that its probabilities match those generated before serialization.

Load only trusted model artifacts

joblib.load() can execute code embedded in a serialized file. A checksum can detect changed bytes, but it does not prove that the original artifact was safe. Load only artifacts produced through a trusted and controlled release process.

Show code
saved_checksum = hashlib.sha256(artifact_path.read_bytes()).hexdigest()
reloaded_pipeline = joblib.load(artifact_path)
reloaded_probability = reloaded_pipeline.predict_proba(X_holdout)[:, 1]

integrity_checks = pd.DataFrame([
    {
        "check": "artifact checksum matches metadata",
        "passed": saved_checksum == metadata["artifact_sha256"],
        "detail": saved_checksum[:16] + "…",
    },
    {
        "check": "reloaded probabilities match",
        "passed": bool(np.allclose(holdout_probability, reloaded_probability, atol=1e-12)),
        "detail": f"maximum absolute difference={np.max(np.abs(holdout_probability - reloaded_probability)):.2e}",
    },
    {
        "check": "holdout release gate",
        "passed": holdout_auc >= deployment_brief["release_gates"]["minimum_holdout_roc_auc"],
        "detail": f"ROC AUC={holdout_auc:.4f}",
    },
])
integrity_checks
check passed detail
0 artifact checksum matches metadata True 7a3ac892ec884570…
1 reloaded probabilities match True maximum absolute difference=0.00e+00
2 holdout release gate True ROC AUC=0.9944
Show code
assert integrity_checks["passed"].all(), "Artifact release gate failed"
print("All artifact integrity and validation gates passed.")
All artifact integrity and validation gates passed.

Implement Request Validation

Validation must fail clearly before the model receives malformed data. The function below rejects non-object payloads, missing and extra fields, booleans, non-numeric values, non-finite values, and values outside the agreed bounds.

Show code
def validate_payload(payload, schema=input_schema):
    if not isinstance(payload, dict):
        raise ValueError("Payload must be a JSON object.")

    required = set(schema["required"])
    received = set(payload)
    missing = sorted(required - received)
    extra = sorted(received - required)
    if missing:
        raise ValueError(f"Missing required fields: {missing}")
    if extra:
        raise ValueError(f"Unexpected fields: {extra}")

    validated = {}
    for feature in schema["required"]:
        value = payload[feature]
        if isinstance(value, bool) or not isinstance(value, (int, float, np.integer, np.floating)):
            raise ValueError(f"{feature!r} must be numeric.")
        value = float(value)
        if not np.isfinite(value):
            raise ValueError(f"{feature!r} must be finite.")
        rules = schema["properties"][feature]
        if value < rules["minimum"] or value > rules["maximum"]:
            raise ValueError(
                f"{feature!r}={value} is outside the accepted range "
                f"[{rules['minimum']:.3f}, {rules['maximum']:.3f}]."
            )
        validated[feature] = value
    return validated

Create a Deterministic Prediction Function

The prediction function returns both the probability and the thresholded class. Returning the release identifier makes downstream logs and investigations traceable.

Show code
def validate_response(response, schema=output_schema):
    required = set(schema["required"])
    received = set(response)
    if received != required:
        raise ValueError(
            f"Response fields do not match the contract: "
            f"missing={sorted(required - received)}; extra={sorted(received - required)}"
        )
    if not isinstance(response["release_id"], str):
        raise ValueError("release_id must be a string")
    if isinstance(response["prediction"], bool) or response["prediction"] not in (0, 1):
        raise ValueError("prediction must be integer 0 or 1")
    for field in ["probability", "threshold"]:
        value = response[field]
        if isinstance(value, bool) or not isinstance(value, (int, float)) or not 0 <= value <= 1:
            raise ValueError(f"{field} must be numeric and between 0 and 1")
    return response

def predict_one(payload, model=reloaded_pipeline, threshold=DECISION_THRESHOLD):
    validated = validate_payload(payload)
    frame = pd.DataFrame([validated], columns=feature_names)
    probability = float(model.predict_proba(frame)[0, 1])
    response = {
        "release_id": RELEASE_ID,
        "prediction": int(probability >= threshold),
        "probability": round(probability, 6),
        "threshold": float(threshold),
    }
    return validate_response(response)

example_request = {feature: float(X_holdout.iloc[0][feature]) for feature in feature_names}
example_response = predict_one(example_request)

(PATHS["outputs"] / "example-request.json").write_text(json.dumps(example_request, indent=2))
(PATHS["outputs"] / "example-response.json").write_text(json.dumps(example_response, indent=2))
example_response
{'release_id': 'model-010-v1',
 'prediction': 1,
 'probability': 0.98564,
 'threshold': 0.5}

Test the Contract and Failure Paths

A deployment test suite should verify expected successes and expected failures. The tests below deliberately mutate the known-good request.

Show code
def run_case(name, payload, should_pass, expected_text=""):
    try:
        response = predict_one(payload)
        observed_pass = True
        detail = f"prediction={response['prediction']}; probability={response['probability']}"
    except Exception as error:
        observed_pass = False
        detail = str(error)

    expectation_met = observed_pass == should_pass
    if expected_text and not observed_pass:
        expectation_met = expectation_met and expected_text in detail
    return {
        "test": name,
        "expected_valid": should_pass,
        "observed_valid": observed_pass,
        "expectation_met": expectation_met,
        "detail": detail,
    }

missing_payload = dict(example_request)
missing_payload.pop(feature_names[0])
extra_payload = {**example_request, "unknown_measure": 1.0}
text_payload = {**example_request, feature_names[1]: "not-a-number"}
range_payload = {
    **example_request,
    feature_names[2]: input_schema["properties"][feature_names[2]]["maximum"] + 1,
}

contract_results = pd.DataFrame([
    run_case("valid request", example_request, True),
    run_case("missing field rejected", missing_payload, False, "Missing required fields"),
    run_case("extra field rejected", extra_payload, False, "Unexpected fields"),
    run_case("text value rejected", text_payload, False, "must be numeric"),
    run_case("out-of-range value rejected", range_payload, False, "outside the accepted range"),
])
contract_results.to_csv(PATHS["tests"] / "contract-test-results.csv", index=False)
contract_results
test expected_valid observed_valid expectation_met detail
0 valid request True True True prediction=1; probability=0.98564
1 missing field rejected False False True Missing required fields: ['mean radius']
2 extra field rejected False False True Unexpected fields: ['unknown_measure']
3 text value rejected False False True 'mean texture' must be numeric.
4 out-of-range value rejected False False True 'mean perimeter'=283.75 is outside the accepted range [21.895, 282.750].
Show code
assert contract_results["expectation_met"].all(), "One or more contract tests failed"
print(f"Contract tests passed: {contract_results['expectation_met'].sum()}/{len(contract_results)}")
Contract tests passed: 5/5

Boundary tests are especially useful for numeric contracts. The following pattern checks that the declared maximum is accepted while a value immediately above it is rejected.

feature = feature_names[0]
at_limit = dict(example_request)
at_limit[feature] = input_schema["properties"][feature]["maximum"]
predict_one(at_limit)  # expected to succeed

above_limit = dict(at_limit)
above_limit[feature] += 0.001
predict_one(above_limit)  # expected to raise ValueError

Run and Export Batch Predictions

Batch inference should reuse the same row-level contract. Include a request identifier supplied by the calling system, but avoid copying direct identifiers or raw feature values into general-purpose logs.

Show code
batch_input = X_holdout.head(12).reset_index(drop=True)
batch_input.insert(0, "request_id", [f"demo-{i:03d}" for i in range(len(batch_input))])

batch_rows = []
for record in batch_input.to_dict(orient="records"):
    request_id = record.pop("request_id")
    batch_rows.append({"request_id": request_id, **predict_one(record)})

batch_predictions = pd.DataFrame(batch_rows)
batch_predictions.to_csv(PATHS["outputs"] / "batch-predictions.csv", index=False)
batch_predictions.head()
request_id release_id prediction probability threshold
0 demo-000 model-010-v1 1 0.985640 0.5
1 demo-001 model-010-v1 1 0.723189 0.5
2 demo-002 model-010-v1 0 0.089121 0.5
3 demo-003 model-010-v1 0 0.038742 0.5
4 demo-004 model-010-v1 1 0.997639 0.5

Generate the API Service Boundary

The service file below is a minimal FastAPI adapter around the same artifact and contract. It exposes /health for release identity and /predict for inference. The generated file is not launched during document rendering; contract behavior has already been executed directly in the notebook kernel.

Show code
app_source = '''from pathlib import Path
import json
import joblib
import numpy as np
import pandas as pd
from fastapi import FastAPI, HTTPException

ROOT = Path(__file__).resolve().parents[1]
RELEASE_ID = "model-010-v1"
MODEL_PATH = ROOT / "artifacts" / f"{RELEASE_ID}.joblib"
SCHEMA_PATH = ROOT / "config" / "input-schema.json"
METADATA_PATH = ROOT / "artifacts" / f"{RELEASE_ID}.metadata.json"

model = joblib.load(MODEL_PATH)
schema = json.loads(SCHEMA_PATH.read_text())
metadata = json.loads(METADATA_PATH.read_text())
features = metadata["features"]
threshold = float(metadata["threshold"])
app = FastAPI(title="CDI Model 010 demonstration service", version=metadata["version"])

def validate(payload):
    missing = sorted(set(features) - set(payload))
    extra = sorted(set(payload) - set(features))
    if missing or extra:
        raise ValueError(f"missing={missing}; extra={extra}")
    clean = {}
    for feature in features:
        value = payload[feature]
        if isinstance(value, bool) or not isinstance(value, (int, float)):
            raise ValueError(f"{feature} must be numeric")
        value = float(value)
        rules = schema["properties"][feature]
        if not np.isfinite(value) or not rules["minimum"] <= value <= rules["maximum"]:
            raise ValueError(f"{feature} is outside the accepted range")
        clean[feature] = value
    return clean

@app.get("/health")
def health():
    return {"status": "ok", "release_id": RELEASE_ID}

@app.post("/predict")
def predict(payload: dict):
    try:
        clean = validate(payload)
    except ValueError as error:
        raise HTTPException(status_code=422, detail=str(error)) from error
    probability = float(model.predict_proba(pd.DataFrame([clean], columns=features))[0, 1])
    return {
        "release_id": RELEASE_ID,
        "prediction": int(probability >= threshold),
        "probability": round(probability, 6),
        "threshold": threshold,
    }
'''

requirements = """fastapi>=0.115,<1
joblib>=1.4,<2
numpy>=2.0,<3
pandas>=2.2,<3
scikit-learn>=1.5,<2
uvicorn[standard]>=0.30,<1
"""

(PATHS["service"] / "app.py").write_text(app_source)
(PATHS["service"] / "requirements.txt").write_text(requirements)

compile(app_source, str(PATHS["service"] / "app.py"), "exec")
print("Generated service/app.py and verified its Python syntax.")
Generated service/app.py and verified its Python syntax.

From the repository root, install the service dependencies and start one local worker:

python -m pip install -r service/requirements.txt
uvicorn service.app:app --host 127.0.0.1 --port 8000

In a second terminal, inspect health:

curl http://127.0.0.1:8000/health

Send the contents of outputs/example-request.json to the prediction endpoint:

curl -X POST http://127.0.0.1:8000/predict \
  -H "Content-Type: application/json" \
  --data @outputs/example-request.json

Define Privacy-Conscious Prediction Logging

Operational logs should support debugging and monitoring without becoming an uncontrolled copy of sensitive inputs. This demonstration records a one-way request fingerprint, release identity, timing, status, predicted class, and probability. In a sensitive system, decide whether even prediction values are appropriate to retain.

Show code
def request_fingerprint(payload):
    canonical = json.dumps(payload, sort_keys=True, separators=(",", ":"))
    return hashlib.sha256(canonical.encode()).hexdigest()[:16]

def predict_with_event(payload, request_id):
    started = time.perf_counter()
    event = {
        "timestamp_utc": datetime.now(timezone.utc).isoformat(),
        "request_id": request_id,
        "request_fingerprint": request_fingerprint(payload),
        "release_id": RELEASE_ID,
    }
    try:
        result = predict_one(payload)
        event.update({
            "status": "success",
            "prediction": result["prediction"],
            "probability": result["probability"],
            "error_type": None,
        })
    except Exception as error:
        result = None
        event.update({
            "status": "failure",
            "prediction": None,
            "probability": None,
            "error_type": type(error).__name__,
        })
    event["latency_ms"] = round((time.perf_counter() - started) * 1000, 3)
    return result, event

event_rows = []
for index, record in X_holdout.head(40).reset_index(drop=True).iterrows():
    _, event = predict_with_event(record.to_dict(), f"window-{index:03d}")
    event_rows.append(event)

# Add one invalid request to exercise failure monitoring.
_, invalid_event = predict_with_event(missing_payload, "window-invalid-001")
event_rows.append(invalid_event)

event_log_path = PATHS["monitoring"] / "prediction-events.jsonl"
event_log_path.write_text("\n".join(json.dumps(row) for row in event_rows) + "\n")
events = pd.DataFrame(event_rows)
events.head()
timestamp_utc request_id request_fingerprint release_id status prediction probability error_type latency_ms
0 2026-08-14T11:04:12.431586+00:00 window-000 09bc6dd6bec85bfa model-010-v1 success 1.0 0.985640 None 1.653
1 2026-08-14T11:04:12.433374+00:00 window-001 0d56e5c859646e2c model-010-v1 success 1.0 0.723189 None 1.138
2 2026-08-14T11:04:12.434546+00:00 window-002 a36cded479386475 model-010-v1 success 0.0 0.089121 None 0.632
3 2026-08-14T11:04:12.435206+00:00 window-003 2e54956733c0e4a0 model-010-v1 success 0.0 0.038742 None 0.567
4 2026-08-14T11:04:12.435798+00:00 window-004 6508993fed952a5f model-010-v1 success 1.0 0.997639 None 0.724

Monitor Service-Level Indicators

Availability, failure rate, and latency describe whether the service is operating. They do not tell you whether the model remains useful or fair. Monitor service, data, prediction, outcome, and subgroup behavior as distinct layers.

Show code
successful = events["status"].eq("success")
service_window = pd.DataFrame([{
    "release_id": RELEASE_ID,
    "requests": len(events),
    "successful_requests": int(successful.sum()),
    "failure_rate": float((~successful).mean()),
    "median_latency_ms": float(events["latency_ms"].median()),
    "p95_latency_ms": float(events["latency_ms"].quantile(0.95)),
    "positive_prediction_rate": float(events.loc[successful, "prediction"].mean()),
}])

service_window["failure_alert"] = service_window["failure_rate"] > 0.05
service_window["latency_alert"] = service_window["p95_latency_ms"] > 250
service_window.to_csv(PATHS["monitoring"] / "service-window.csv", index=False)
service_window.round(4)
release_id requests successful_requests failure_rate median_latency_ms p95_latency_ms positive_prediction_rate failure_alert latency_alert
0 model-010-v1 41 40 0.0244 0.554 1.281 0.675 False False

The single deliberate invalid request remains below the > 5% failure trigger in this 41-request demonstration window. In practice, choose a minimum window size so one request cannot create or suppress an unstable alert.

Build a Reference Data Profile

Store aggregate reference statistics instead of the complete training dataset when that is sufficient. The profile below records quantiles used to create fixed monitoring bins.

Show code
profile_rows = []
for feature in feature_names:
    values = X_train[feature].astype(float)
    quantiles = values.quantile([0, 0.1, 0.25, 0.5, 0.75, 0.9, 1.0]).to_dict()
    profile_rows.append({
        "feature": feature,
        "missing_rate": float(values.isna().mean()),
        "mean": float(values.mean()),
        "std": float(values.std()),
        **{f"q{int(q * 100):02d}": float(value) for q, value in quantiles.items()},
    })

reference_profile = pd.DataFrame(profile_rows)
reference_profile.to_csv(PATHS["monitoring"] / "reference-profile.csv", index=False)
reference_profile.round(3)
feature missing_rate mean std q00 q10 q25 q50 q75 q90 q100
0 mean radius 0.0 14.121 3.613 6.981 10.220 11.650 13.270 15.780 19.574 28.110
1 mean texture 0.0 19.341 4.392 10.380 14.098 16.175 18.800 21.710 25.172 39.280
2 mean perimeter 0.0 91.933 24.961 43.790 65.196 74.720 85.790 103.900 129.880 188.500
3 mean area 0.0 656.740 362.958 143.500 320.960 416.150 545.200 782.650 1204.800 2501.000
4 mean smoothness 0.0 0.096 0.014 0.053 0.080 0.086 0.095 0.105 0.114 0.145
5 worst radius 0.0 16.290 4.985 7.930 11.160 12.980 14.900 18.775 23.726 36.040
6 worst texture 0.0 25.771 6.246 12.870 17.810 21.140 25.230 29.990 33.958 49.540
7 worst perimeter 0.0 107.416 34.652 50.410 71.850 84.135 97.170 125.250 159.400 251.200
8 worst area 0.0 888.260 592.667 185.200 377.980 513.500 677.900 1077.000 1718.000 4254.000
9 worst concavity 0.0 0.271 0.212 0.000 0.041 0.114 0.228 0.380 0.563 1.252

Calculate Population Stability Index

Population Stability Index (PSI) compares proportions in fixed reference bins. It is a screening signal, not proof that model performance changed. Small monitoring windows can be noisy, and thresholds must reflect the domain and consequences.

Show code
def population_stability_index(reference, current, bins=10, epsilon=1e-6):
    reference = pd.Series(reference).dropna().astype(float)
    current = pd.Series(current).dropna().astype(float)
    edges = np.unique(reference.quantile(np.linspace(0, 1, bins + 1)).to_numpy())
    if len(edges) < 3:
        return 0.0
    edges[0], edges[-1] = -np.inf, np.inf
    reference_share = pd.cut(reference, edges, include_lowest=True).value_counts(normalize=True, sort=False)
    current_share = pd.cut(current, edges, include_lowest=True).value_counts(normalize=True, sort=False)
    reference_share = np.clip(reference_share.to_numpy(), epsilon, None)
    current_share = np.clip(current_share.to_numpy(), epsilon, None)
    return float(np.sum((current_share - reference_share) * np.log(current_share / reference_share)))

Create a reproducible monitoring window and introduce a moderate shift in one feature so the alert workflow is visible.

Show code
current_window = X_holdout.copy().reset_index(drop=True)
shifted_feature = "mean texture"
current_window[shifted_feature] = current_window[shifted_feature] * 1.12

drift_rows = []
for feature in feature_names:
    psi = population_stability_index(X_train[feature], current_window[feature])
    drift_rows.append({
        "feature": feature,
        "reference_missing_rate": float(X_train[feature].isna().mean()),
        "current_missing_rate": float(current_window[feature].isna().mean()),
        "psi": psi,
        "psi_alert": psi > 0.25,
    })

drift_summary = pd.DataFrame(drift_rows).sort_values("psi", ascending=False)
drift_summary.to_csv(PATHS["monitoring"] / "drift-summary.csv", index=False)
drift_summary.round(4)
feature reference_missing_rate current_missing_rate psi psi_alert
1 mean texture 0.0 0.0 0.3858 True
6 worst texture 0.0 0.0 0.1271 False
4 mean smoothness 0.0 0.0 0.1226 False
7 worst perimeter 0.0 0.0 0.1048 False
8 worst area 0.0 0.0 0.1015 False
5 worst radius 0.0 0.0 0.0922 False
2 mean perimeter 0.0 0.0 0.0876 False
3 mean area 0.0 0.0 0.0618 False
9 worst concavity 0.0 0.0 0.0609 False
0 mean radius 0.0 0.0 0.0465 False
Show code
plot_data = drift_summary.sort_values("psi")
colors = np.where(plot_data["psi_alert"], "#b33a3a", "#2f6f4e")
fig, ax = plt.subplots(figsize=(8, 4.8))
ax.barh(plot_data["feature"], plot_data["psi"], color=colors)
ax.axvline(0.25, color="#b33a3a", linestyle="--", linewidth=1.5, label="alert threshold")
ax.set_xlabel("Population Stability Index")
ax.set_ylabel("")
ax.legend(frameon=False)
ax.grid(axis="x", alpha=0.2)
plt.tight_layout()
plt.show()

Population Stability Index by feature for the demonstration monitoring window.

Interpret Monitoring Signals Carefully

Use the signals as prompts for investigation:

  • a schema failure may indicate an upstream interface change;
  • rising latency may indicate resource pressure or dependency failure;
  • feature drift may reflect a real population change, a measurement change, or a pipeline defect;
  • prediction drift can occur even when individual feature PSI values remain modest;
  • stable inputs do not guarantee stable outcomes; and
  • performance monitoring requires delayed ground truth collected under an approved process.

Do not automatically retrain or roll back from a single noisy statistic. Confirm data lineage, sample size, timing, subgroup effects, operational incidents, and outcome evidence.

When approved labels become available, join them to predictions using a controlled identifier and calculate metrics by time window and relevant subgroup.

evaluation = predictions.merge(outcomes, on="request_id", validate="one_to_one")
window_auc = roc_auc_score(evaluation["observed_outcome"], evaluation["probability"])
subgroup_auc = (
    evaluation.groupby("approved_subgroup", observed=True)
    .apply(lambda group: roc_auc_score(group["observed_outcome"], group["probability"]))
)

Before implementing this pattern, document label delay, missing outcomes, intervention effects, consent, retention, access, and whether subgroup evaluation is statistically meaningful.

Define Alert Ownership and Response

An alert without an owner and action is noise. The response matrix below distinguishes investigation, escalation, and immediate rollback.

Show code
response_matrix = pd.DataFrame([
    ["schema failure rate", "> 5%", "service owner", "inspect upstream payload changes", "pause traffic if sustained"],
    ["p95 latency", "> 250 ms", "platform owner", "inspect capacity and dependencies", "scale or revert release"],
    ["feature PSI", "> 0.25", "model owner", "validate lineage and population shift", "hold retraining decision for review"],
    ["critical safety/privacy defect", "confirmed", "incident lead", "contain and notify", "immediate rollback or shutdown"],
    ["outcome performance", "below approved floor", "model-risk owner", "review labels and subgroup results", "rollback or suspend"],
], columns=["signal", "trigger", "owner", "first_action", "possible_decision"])
response_matrix
signal trigger owner first_action possible_decision
0 schema failure rate > 5% service owner inspect upstream payload changes pause traffic if sustained
1 p95 latency > 250 ms platform owner inspect capacity and dependencies scale or revert release
2 feature PSI > 0.25 model owner validate lineage and population shift hold retraining decision for review
3 critical safety/privacy defect confirmed incident lead contain and notify immediate rollback or shutdown
4 outcome performance below approved floor model-risk owner review labels and subgroup results rollback or suspend

Rehearse a Rollback Decision

Rollback must be possible before it is needed. A real rehearsal verifies artifact availability, configuration compatibility, data migration implications, routing, smoke tests, and authority to act.

This demonstration treats the intentionally shifted PSI signal as a reason to open an investigation. It does not automatically replace the release.

Show code
active_alerts = {
    "service_failure": bool(service_window.loc[0, "failure_alert"]),
    "service_latency": bool(service_window.loc[0, "latency_alert"]),
    "feature_drift": bool(drift_summary["psi_alert"].any()),
    "critical_incident": False,
}

if active_alerts["critical_incident"]:
    recommended_action = "immediate rollback"
elif active_alerts["service_failure"] or active_alerts["service_latency"]:
    recommended_action = "escalate and prepare rollback"
elif active_alerts["feature_drift"]:
    recommended_action = "investigate drift; keep rollback ready"
else:
    recommended_action = "continue monitored operation"

rollback_rehearsal = {
    "release_id": RELEASE_ID,
    "rehearsal_time_utc": datetime.now(timezone.utc).isoformat(),
    "active_alerts": active_alerts,
    "recommended_action": recommended_action,
    "previous_release_required": "model-010-v0",
    "preconditions_checked": [
        "previous artifact location defined",
        "schema compatibility must be verified",
        "traffic switch authority assigned",
        "post-rollback smoke test specified",
    ],
    "rehearsal_only": True,
}
(PATHS["outputs"] / "rollback-rehearsal.json").write_text(json.dumps(rollback_rehearsal, indent=2))
pd.DataFrame([rollback_rehearsal])
release_id rehearsal_time_utc active_alerts recommended_action previous_release_required preconditions_checked rehearsal_only
0 model-010-v1 2026-08-14T11:04:12.678307+00:00 {'service_failure': False, 'service_latency': False, 'feature_drift': True, 'critical_incident': False} investigate drift; keep rollback ready model-010-v0 [previous artifact location defined, schema compatibility must be verified, traffic switch authority assigned, post-rollback smoke test specified] True
A first release needs a safe fallback

This practical names a hypothetical previous version to make the rollback contract explicit. If no earlier safe model exists, the fallback may be a rules-based process, manual review, or service shutdown. “Keep the new model running” is not a fallback.

Create the Release Manifest

The release manifest gathers the identity, checksums, contracts, tests, monitoring configuration, and decision state needed for review.

Show code
release_manifest = {
    "release_id": RELEASE_ID,
    "created_at_utc": datetime.now(timezone.utc).isoformat(),
    "decision": "candidate_ready_for_manual_review",
    "artifact": {
        "path": str(artifact_path.relative_to(ROOT)),
        "sha256": artifact_sha256,
    },
    "metadata": str(metadata_path.relative_to(ROOT)),
    "contracts": ["config/input-schema.json", "config/output-schema.json"],
    "service": ["service/app.py", "service/requirements.txt"],
    "test_evidence": "tests/contract-test-results.csv",
    "monitoring_evidence": [
        "monitoring/service-window.csv",
        "monitoring/reference-profile.csv",
        "monitoring/drift-summary.csv",
    ],
    "rollback_evidence": "outputs/rollback-rehearsal.json",
    "release_gates": {
        "artifact_integrity": bool(integrity_checks["passed"].all()),
        "contract_tests": bool(contract_results["expectation_met"].all()),
        "manual_review": False,
    },
}
manifest_path = PATHS["artifacts"] / "release-manifest.json"
manifest_path.write_text(json.dumps(release_manifest, indent=2))
pd.DataFrame([
    {"gate": gate, "passed": passed}
    for gate, passed in release_manifest["release_gates"].items()
])
gate passed
0 artifact_integrity True
1 contract_tests True
2 manual_review False

The manual-review gate is intentionally False. Rendering the practical creates evidence for review; it does not authorize release.

Create the Model Deployment Report

The report is saved as a Markdown file. Expand the preview below only when you want to inspect its generated contents.

Show code
alerted_features = drift_summary.loc[drift_summary["psi_alert"], "feature"].tolist()
report = f"""# Model Deployment Report



## Release identity

- Release: `{RELEASE_ID}`
- Artifact: `{artifact_path.name}`
- SHA-256: `{artifact_sha256}`
- Framework: scikit-learn {sklearn.__version__}



## Intended and prohibited use

This release candidate demonstrates controlled deployment of a binary classifier for education, portfolio evidence, and local technical testing. It must not be used for clinical or other real-world decisions affecting people.



## Model handoff evidence

- Required numeric features: {len(feature_names)}
- Demonstration holdout rows: {len(X_holdout)}
- Demonstration holdout ROC AUC: {holdout_auc:.4f}
- Decision threshold: {DECISION_THRESHOLD:.2f}
- Reloaded predictions matched pre-serialization predictions: {bool(integrity_checks.loc[integrity_checks['check'].eq('reloaded probabilities match'), 'passed'].iloc[0])}



## Contract and service evidence

- Contract tests passed: {int(contract_results['expectation_met'].sum())}/{len(contract_results)}
- Single-request and batch inference paths executed successfully.
- The generated FastAPI service passed Python syntax compilation.
- Raw feature values are excluded from the demonstration prediction-event log.



## Monitoring evidence

- Requests in demonstration window: {int(service_window.loc[0, 'requests'])}
- Failure rate: {service_window.loc[0, 'failure_rate']:.2%}
- p95 local inference latency: {service_window.loc[0, 'p95_latency_ms']:.3f} ms
- Features above PSI alert threshold: {alerted_features if alerted_features else 'none'}

The drift result is intentionally simulated to exercise investigation and rollback reasoning. It is not evidence of a real production shift.



## Recovery readiness

The rollback decision logic was executed. The current recommendation is: **{recommended_action}**. A real release must verify the previous safe artifact or an alternative fallback, routing authority, schema compatibility, and a post-rollback smoke test.



## Release decision

Automated artifact and contract gates passed. The candidate remains **pending manual review**. Promotion requires an accountable reviewer to evaluate the evidence, resolve alerts, confirm operational ownership, and update the release manifest.
"""

report_path = PATHS["reports"] / "model-deployment-report.md"
report_path.write_text(report)
display(Markdown(report))

Model Deployment Report

Release identity

  • Release: model-010-v1
  • Artifact: model-010-v1.joblib
  • SHA-256: 7a3ac892ec884570e8e993c02d3e4212e2f58b159f93bb2fb4e8fed418eb9719
  • Framework: scikit-learn 1.9.0

Intended and prohibited use

This release candidate demonstrates controlled deployment of a binary classifier for education, portfolio evidence, and local technical testing. It must not be used for clinical or other real-world decisions affecting people.

Model handoff evidence

  • Required numeric features: 10
  • Demonstration holdout rows: 114
  • Demonstration holdout ROC AUC: 0.9944
  • Decision threshold: 0.50
  • Reloaded predictions matched pre-serialization predictions: True

Contract and service evidence

  • Contract tests passed: 5/5
  • Single-request and batch inference paths executed successfully.
  • The generated FastAPI service passed Python syntax compilation.
  • Raw feature values are excluded from the demonstration prediction-event log.

Monitoring evidence

  • Requests in demonstration window: 41
  • Failure rate: 2.44%
  • p95 local inference latency: 1.281 ms
  • Features above PSI alert threshold: [‘mean texture’]

The drift result is intentionally simulated to exercise investigation and rollback reasoning. It is not evidence of a real production shift.

Recovery readiness

The rollback decision logic was executed. The current recommendation is: investigate drift; keep rollback ready. A real release must verify the previous safe artifact or an alternative fallback, routing authority, schema compatibility, and a post-rollback smoke test.

Release decision

Automated artifact and contract gates passed. The candidate remains pending manual review. Promotion requires an accountable reviewer to evaluate the evidence, resolve alerts, confirm operational ownership, and update the release manifest.

Export and Verify Results

Verify that every expected artifact exists, is non-empty, and contains the expected release identity where applicable.

Show code
expected_outputs = [
    brief_path,
    artifact_path,
    metadata_path,
    PATHS["config"] / "input-schema.json",
    PATHS["config"] / "output-schema.json",
    PATHS["service"] / "app.py",
    PATHS["service"] / "requirements.txt",
    PATHS["tests"] / "contract-test-results.csv",
    PATHS["monitoring"] / "reference-profile.csv",
    PATHS["monitoring"] / "prediction-events.jsonl",
    PATHS["monitoring"] / "service-window.csv",
    PATHS["monitoring"] / "drift-summary.csv",
    PATHS["outputs"] / "example-request.json",
    PATHS["outputs"] / "example-response.json",
    PATHS["outputs"] / "batch-predictions.csv",
    PATHS["outputs"] / "rollback-rehearsal.json",
    manifest_path,
    report_path,
]

verification = pd.DataFrame([
    {
        "path": str(path.relative_to(ROOT)),
        "exists": path.exists(),
        "non_empty": path.exists() and path.stat().st_size > 0,
        "size_bytes": path.stat().st_size if path.exists() else 0,
    }
    for path in expected_outputs
])
verification
path exists non_empty size_bytes
0 config/deployment-brief.json True True 1081
1 artifacts/model-010-v1.joblib True True 2417
2 artifacts/model-010-v1.metadata.json True True 763
3 config/input-schema.json True True 1444
4 config/output-schema.json True True 598
5 service/app.py True True 1941
6 service/requirements.txt True True 110
7 tests/contract-test-results.csv True True 468
8 monitoring/reference-profile.csv True True 1191
9 monitoring/prediction-events.jsonl True True 10617
10 monitoring/service-window.csv True True 209
11 monitoring/drift-summary.csv True True 539
12 outputs/example-request.json True True 261
13 outputs/example-response.json True True 99
14 outputs/batch-predictions.csv True True 494
15 outputs/rollback-rehearsal.json True True 580
16 artifacts/release-manifest.json True True 870
17 reports/model-deployment-report.md True True 1879
Show code
assert verification[["exists", "non_empty"]].all().all(), "One or more deployment outputs are missing or empty"
assert json.loads(metadata_path.read_text())["release_id"] == RELEASE_ID
assert json.loads(manifest_path.read_text())["release_id"] == RELEASE_ID
assert artifact_sha256 == hashlib.sha256(artifact_path.read_bytes()).hexdigest()
assert "pending manual review" in report_path.read_text().lower()
print(f"Verified {len(verification)} deployment outputs. Candidate remains pending manual review.")
Verified 18 deployment outputs. Candidate remains pending manual review.

Portfolio Evidence

Use the completed repository to demonstrate that you can move beyond model training. Strong evidence includes:

  • a clear release brief and bounded model-use statement;
  • versioned, fingerprinted artifacts with reproducibility checks;
  • explicit input and output contracts;
  • executable success and failure tests;
  • a thin service boundary that reuses the complete pipeline;
  • privacy-conscious operational logging;
  • separate service, data, prediction, and outcome monitoring plans;
  • predeclared alert ownership and response actions; and
  • a rollback rehearsal with an honest fallback.

Do not present a rendered page alone as proof of production readiness. Explain which parts were executed locally, which controls are demonstrations, and what infrastructure or governance would still be required.

Quality Checks

Before requesting release approval, confirm that:

  • the serialized object contains preprocessing and model steps;
  • feature order comes from versioned metadata rather than caller order;
  • missing, extra, invalid, and implausible values are rejected;
  • class meaning and threshold are explicit;
  • model and schema versions are traceable in responses and logs;
  • tests cover both valid and invalid paths;
  • logs exclude unnecessary raw or identifying data;
  • monitoring windows and minimum sample sizes are defined;
  • drift alerts trigger investigation rather than blind retraining;
  • outcome and subgroup monitoring plans address label delay and missingness;
  • a safe fallback and accountable rollback authority exist; and
  • manual approval is recorded separately from automated test success.

Reflection and Next Steps

Write brief answers to these questions:

  1. Which assumption in the input contract is most likely to fail first?
  2. What information would you need to distinguish real population drift from a broken upstream pipeline?
  3. Which logs are necessary for incident investigation, and which would create avoidable privacy risk?
  4. What minimum evidence would justify continuing operation after a PSI alert?
  5. If ground-truth outcomes arrive after 90 days, what early signals can you monitor without pretending they measure performance?
  6. Who has authority to approve, pause, roll back, and retire the model?
  7. What is the safest fallback if no earlier model version exists?

For a stronger extension, containerize the service, add automated API tests, generate a software bill of materials, sign the artifact, run load and security tests, and deploy to a non-production environment with controlled traffic.

Completion Checklist

Practical Complete

You have built a complete model-deployment evidence package: a reproducible artifact, explicit contracts, validated inference paths, an API boundary, operational logs, monitoring signals, response rules, rollback evidence, and a release manifest.

The final lesson is simple: deployment is not the moment a model goes live. It is the controlled process that makes the model identifiable, testable, observable, accountable, and reversible throughout its operational life.

© Complex Data Insights | CDI Practicals

Hands-on exercises and step-by-step tools