Skip to content
C.W.K.
Stream
Lesson 01 of 05 · published

End-to-End Workflow

~28 min · workflow, end-to-end

Level 0Scout
0 XP0/48 lessons0/11 achievements
0/120 XP to next level120 XP to go0% complete

Build one complete path first

A durable project moves through contract → ingestion and checks → deployment-shaped split → preprocessing → baseline → candidate comparison → untouched evaluation → calibration and thresholding when needed → artifact → release → monitoring. Build the thinnest runnable version of that path before optimizing one stage in isolation.

The problem contract governs every stage

Write the prediction unit, decision owner, target, time of prediction, legal inputs, error costs, and success metric before choosing an algorithm. This determines the split and prevents an impressive score from answering the wrong question.

Audit and freeze data as soon as it arrives

Check schema, units, ranges, duplicates, missingness, label timing, and entity keys. Version the raw snapshot or reproducible query and freeze the test boundary. Data changes after an experiment must create a new traceable version rather than silently moving rows.

Keep preprocessing and model in one pipeline

Fit imputers, encoders, scalers, selectors, and the estimator together inside each training fold. The same raw-row interface must run during serving. Add fixtures around time boundaries, missing values, and unseen categories to catch offline-online divergence.

Tune only after a small baseline

Record a rule, human process, mean predictor, or simple linear model first. Compare more complex candidates on identical folds and the decision metric. Tuning is justified only after the baseline exposes a valuable gap.

Separate probability from action

When classification decisions use probability, validate calibration and choose a threshold from cost and capacity. Store score, model version, threshold, policy version, and final action separately so later analysis can distinguish model and policy failures.

Use a folder structure that remains readable

ml_project/
├── data/{raw,interim,processed}
├── notebooks/
├── src/
│   ├── contract.py
│   ├── features.py
│   ├── train.py
│   ├── eval.py
│   └── predict.py
├── tests/
├── artifacts/
└── README.md

Notebooks support exploration; repeatable training and evaluation belong in versioned code. Keep sensitive or large data out of source control and document authorized retrieval.

Verify reproducibility and the live system

Pin the environment and record code revision, data snapshot, feature contract, parameters, metrics, and artifact checksum. Exact bits may vary across hardware, so document tolerances. Load released bytes in a clean process, score contract fixtures, verify the real endpoint, observe model identity and latency, and rehearse rollback. “Done” means deployed behavior traces back to the experiment that justified it.

Code

A trainable end-to-end script·python
import joblib
from sklearn.pipeline import Pipeline
from sklearn.linear_model import LogisticRegression
from src.contract import load_contract
from src.features import build_preprocessor
from src.eval import evaluate

def main():
    contract = load_contract("contracts/churn.yaml")
    df = load_data(contract)
    X, y = df[contract.features], df[contract.target]
    pipe = Pipeline([("pre", build_preprocessor(contract)), ("clf", LogisticRegression(max_iter=1000))])
    pipe.fit(X, y)
    evaluate(pipe, X, y, contract)
    joblib.dump(pipe, contract.artifact_path)

if __name__ == "__main__":
    main()
Pin everything that influences the artifact·yaml
experiment:
  id: churn_2026_05_03_a
  data_hash: a8f1d8e9
  git_commit: 4f7c2e1
  random_seed: 7
  python: 3.12.4
  packages:
    scikit-learn: 1.5.0
    lightgbm: 4.5.0
  metrics:
    pr_auc: 0.317
    recall_at_p70: 0.62

External links

Exercise

Take your latest notebook and refactor it into a src/ module that can be invoked as python -m src.train --config contracts/your_problem.yaml. Verify a fresh kernel can produce the same artifact and metrics.

Progress

Progress is local-only — sign in to sync across devices.
Spotted a bug or have feedback on this page?Report an Issue

Comments 0

🔔 Reply notifications (sign in)
Sign inPlease sign in to comment.

No comments yet — be the first.