PRACTITIONERCHAPTER 08

Taking a model from notebook to production

A notebook number is a claim about the past. Scope the decision, the labels, the baseline and the owner before you build, and ship the simplest thing that earns its place

45 MINDATA AND MLUPDATED 2026-11-21
PREDICT

Adetoun's notebook scores an AUC of 0.97 on a random 20% hold-out of eighteen months of payout batches. Only five of the batches are confirmed fraud. Before anyone starts to build a service around it, what is the most important thing to check?

Most data science is done in a notebook, and most of the value of a model arrives only when it runs somewhere without you. The distance between the two is where projects die quietly. The model is accurate and nobody uses it, or it is deployed and nobody notices when it stops working, or it performs well on history and badly on the next quarter. This chapter is about closing that distance, and its main claim is that most of the closing happens on paper, before the training run.

The artefact is a model scoping document: three pages that say what the model is for, what it will be fed, what it replaces, how it will be served and who will own it. It is the data scientist’s counterpart to a design document, and it is where you find out that you do not need the model, or that you need something quite different.

A notebook is a claim about the past

A notebook shows that on some historical rows, with features computed one way, a model scored well on a split you chose. It says nothing yet about next month. Production adds three gaps.

Gap The question How it shows up
Data Will the labels and features I used exist, in the same form, at the moment of decision? A great score that disappears when the feature is computed live
System How is the score produced, how fast, and what happens when it is wrong or missing? A flag that arrives after the payout has run, or a service outage that blocks payroll
People Who owns the model after launch, who reads its flags, and who retrains it? A model nobody has looked at in nine months

D. Sculley and colleagues made the general point in their 2015 paper on hidden technical debt in machine learning systems: a model is a small part of a real system, and the quick gains it gives carry maintenance costs that are easy to miss. Google’s “Rules of Machine Learning” puts the practical form first: the guide’s first rule is not to be afraid to launch a product without machine learning. Both are in the reading. You do not have to agree with every rule to take the habit: look at everything around the model before you look at the model.

Scope before you build

A scoping document answers ten questions. Teams skip them because they feel like delay, and then pay for each one later at a worse price.

Question What a good answer looks like What goes wrong without it
What decision does the score feed? A named action and a named person: hold a batch, a reviewer calls the customer A score that nobody is obliged to act on
What are the two mistakes worth? A cost for a wrongly held batch and a cost for a missed one, from finance, not from you A threshold chosen by feel
What labels exist? A count, a source, and how long they take to arrive Training on five cases, or on last week’s batches that look clean only because nobody has complained yet
What is the baseline? The current process or a few rules, with their numbers on the same data A model celebrated for beating nothing
Which features exist at decision time? A table of feature, source and the moment it is known Leakage and skew
How is it served? Batch or online, how often, how fast, from where A real-time service built for a decision made once a day
What happens when it fails? Fail open or closed, written down, with a reason The failure decision made by whoever is on call at 05:50
How do we roll it out? Shadow first, then act, with a way back A launch that is also the first test
Who owns it? A named person, a review rhythm, a retraining trigger Drift nobody sees
When do we stop or change course? Written exit criteria A model that survives because nobody can say it has failed

Notice that only one of the ten is about the model. Asking the right question is the same discipline applied to an analysis. Here it is applied to a system.

Rules, a model, or something you buy

Before you train anything, write the baseline. For Ferrowave’s payout flag the baseline is a rule: flag a batch when a large share of its lines are accounts the platform has not seen before. It takes an afternoon, anyone can read it, and the customer success team can argue with it. A model must beat it by enough to justify the extra machinery.

A model earns its place when most of these hold.

  • There are enough labels. Enough means many cases of each kind, not a few. There is no universal count, so treat any figure you read as a rule of thumb and ask whether a split by time still leaves positives in the test period.
  • The rules have run out. You have tuned them and the remaining mistakes follow patterns too many and too subtle to write by hand.
  • Mistakes are expensive enough to pay for the maintenance. Sculley and colleagues are clear that the bill arrives after launch.
  • The inputs will look like the training data. If the product or the customers are changing quickly, the model is aimed at a target that moves.

Compare Ojaline’s delivery-time model, the one in a data scientist’s week. Every delivery labels itself the moment it ends, so there are millions of examples, the target is a number, and the rule baseline has a measured error of 14 minutes against 11 for the candidate. That is a model problem. Ferrowave’s payout fraud has five labelled batches in eighteen months, and the labels come from customers who notice and write in. It is not, yet.

Three options sit between “model” and “nothing”.

Option Fits when Costs you
Rules Few labels, a known pattern, a need for explanations Rules rot; someone must tune them as customers change
A model Plenty of labels, many weak signals, rules saturated Pipelines, monitoring, retraining, an owner, and explanations people accept
A vendor score The vendor sees many more cases than you can, and the data may lawfully leave Opaque logic, a per-call price, and sending your customers’ payee data to a third party

The Fraud track will teach writing and tuning rules properly; that chapter is not yet written. For the scoring side at card authorisation, see machine-learning fraud scoring, which this chapter leans on for time splits and label delay.

Why the notebook number lies

Four things inflate a notebook score. Each is cheap to check and expensive to find later.

A leaky feature. Adetoun’s strongest feature is the number of batches a payee account appears in over all time. Fraudulent accounts are used once, so the feature separates them almost perfectly. But at 17:00 on the evening of the batch, the future batches are not there to count. Removing that one feature takes the notebook’s AUC from 0.97 to 0.71 in the worked example below. The data leakage lesson has the family of mistakes: copies on both sides of a split, the same customer on both sides, and information from after the cut. For every feature, write when it becomes known.

A random split on data that moves through time. Fraud comes in bursts and new methods appear. Split by time: train on everything before a date, test on everything after. If the test period has no positives left, you have learned that you cannot measure this model yet, which is a finding.

Tiny positives. Four catches out of five known cases is a recall of 80%, but an exact 95% confidence interval for four in five runs from about 28% to 99%. Three in five runs from about 15% to 95%. With so few cases, a difference between two rules is not a difference. Write the interval next to the number.

Tuning on the cases that inspired the rule. If you wrote the threshold after reading the five fraud cases, the catch rate on those five is a description of them, not a test. Say so in the document.

Then there is training-serving skew: the feature is computed one way in the notebook and a different way in the service. The notebook counts “new payee” from a table refreshed nightly; the service looks it up in the live ledger. Zinkevich’s rules deal with this directly, and the cure is plain engineering: one function computes each feature, and both the training job and the service call it.

Price the mistakes, then count the reviewers

A flag is a hold: the batch waits, someone phones the customer’s approver, and the batch runs or does not. Two costs follow.

  • C, a wrongly held batch: twenty minutes of a customer success reviewer at ₦7,500 an hour is ₦2,500, plus the risk that the customer’s staff are paid late. (Illustrative figures; take yours from finance and operations.)
  • L, a missed fraud: recall effort, goodwill credits and the risk of losing the customer. Say finance puts it at ₦1.5m a case, well below the ₦14.21m that left the customer’s account, because the customer carries most of the loss.

Holding pays when the chance that a flagged batch is fraud exceeds C divided by C plus L, which is 2,500 / 1,502,500, or 0.17%. The fraud scoring chapter derives the same rule for card declines. A rule that flags 1.5% of batches and is right in 0.8% of the flags clears the bar by a factor of about five. The 0.8% is four caught frauds in 486 flags.

Then check the load. 486 flags over eighteen months is 27 a month, about nine hours of reviewer time. A flag rule that produced 400 a month would break the process however good the score. The threshold is set by two things at once: the break-even chance and what the people downstream can handle.

The shape of the serving

Choose it from the decision, not from fashion. A payroll batch is submitted the evening before and paid at 06:00, so the check needs minutes, not milliseconds. A nightly or on-submission batch job is enough, and it avoids a real-time service whose uptime would then matter more than the model.

Write down six things.

  1. When it runs. At submission, and again if the approver edits the file. A batch submitted for immediate execution needs the same check before it starts, so the hold has to exist for on-demand batches as well as those waiting for 06:00. Staff pay is promised for 07:00, so a hold decision must be possible before the 06:00 executor run.
  2. What it does. Place the batch in a hold state, notify the customer’s approver, and tell the reviewer why, in plain words (“31% of lines are accounts never seen before”). A flag with no reason is a flag nobody trusts. Payouts Core owns the hold state, and Wolfgang, an engineer there, builds the hook; the data scientist does not edit the executor.
  3. What happens on failure. Fail open or closed? For payroll, a missed check is a risk, but an unpaid payroll harms hundreds of people at once, so the usual choice is to let the batch run and queue it for review in the morning. The answer is a business decision; your job is to put it in front of the person who owns it.
  4. What is logged. Every score, every feature value and every outcome, so later you can rebuild what the model saw.
  5. How it is rolled out. First in shadow: it scores real batches and flags nothing, and you compare its flags with what reviewers would have done. Then it holds batches, with a switch that turns it off in one step.
  6. How it is versioned. A version number on every score, so a change to a rule or a model can be tied to a change in behaviour.

Google’s MLOps guide describes how teams move from manual, notebook-driven steps towards automated pipelines. You do not need the top level at the start. You need to be able to reproduce the model from code and data you can name.

After launch

A model is not finished when it ships. Three jobs start.

Monitor. Watch inputs (has the share of new payees changed?), flags (do volumes match the shadow period?) and outcomes (what did reviewers find?). The next chapter in this track, monitoring models and drift, goes into drift in detail.

Collect labels. The reviewer’s outcome on each hold (genuine, error, fraud) is the best label source you have. Beware its bias: only flagged batches are reviewed, so the labels describe what the rule already finds. Send a small random sample of unflagged batches for review too, one in fifty is a common starting point, which is a rule of thumb and not a standard.

Decide when to retrain, or to build the model at all. Write the trigger in the document: for example, revisit when there are thirty confirmed cases, or when review load passes capacity.

Where practitioners disagree

Hand over, or own it end to end. Some companies have the data scientist hand a notebook to an ML engineer who rewrites it for production. Others have the scientist run the whole path, with platform engineers owning the serving. The handover scales to many models and loses knowledge at every step. End to end keeps context and does not scale past a few models. At Ferrowave there is one data scientist and no ML engineer, so the question is moot: Adetoun owns the model and the engineers who own the surrounding systems own the hold and the executor.

Platform first, or one model first. The case for a platform is that every model needs the same plumbing. The case against is that you do not know what plumbing you need until a model has run. Most small teams are better off shipping one model by hand and building the platform from what hurt.

Buy or build. A vendor score can be right where the vendor sees far more cases than you will. It can be wrong when the signal is specific to your customers’ payroll files. Ask what data it needs and where that data goes before you ask what it costs.

Where it goes wrong

Starting with the algorithm. The notebook gets a week of effort and the scoping gets none.

A baseline nobody wrote. The model is declared a success against a rule that was never run.

A real-time system for a daily decision. It costs more to run and adds an outage to a process that did not have one.

The silent failure. Nobody decided what happens when the model is down, so the answer is decided at 05:50 by whoever is on call.

No owner. The model works for a year and then stops, and nobody had the job of noticing. Sculley and colleagues call this kind of cost debt because it compounds quietly.

Launching with the switch off the table. There is no way to turn it off in a minute.

Day to day

Work on a production model is a rhythm of short loops around the build.

At the start, spend a day writing the scoping document before any training. Share the draft with the engineer who will own the hook, the person who will review the flags, and finance. Expect the cost-of-mistakes conversation to take longer than any other.

While you build, keep the notebook, but move feature code into functions the service can import. Review it with an engineer, as in any code review. Run the time split on day one, not at the end.

During shadow running, which might last four weeks, read the flags every day with the reviewer. Disagreements between reviewer and rule are the cheapest labels you will ever collect.

Weekly after launch, a thirty-minute review with the owner of the process: flag volume, holds, outcomes, anything surprising. Monthly, check the input mix against the training data, re-read the exit criteria, and update the document’s version. Quarterly, ask whether the model is still worth its upkeep. Some are not, and retiring one is a success.

BY ORG SIZE
STARTUPunder 30 people

There is rarely a data scientist, and the “model” is a spreadsheet filter or a few lines in the payout code, written by the engineer who saw the fraud. That is usually the right size. The risk is writing a rule once and never looking at it again, so put the rule in version control, note the date and the cases it came from, and look at its flags monthly. Buy a vendor score only if one person can say why it beats the rule.

SCALE-UP30 to 300

This is Ferrowave: one data scientist, engineers who own the system around the model, and no ML platform. The scoping document does the work of a platform. It decides who owns the hold, who reviews the flags, and who retrains. Resist building a feature store for one model. Ship the model by hand, keep a short log of what was painful, and build tooling only for what hurt twice.

ENTERPRISE300 and up

Models are common and so is a platform: a registry, a shared way to serve and monitor, a model risk process. Ojaline’s data team, about ten people, has a delivery-time model on the checkout screen and still needs an owner outside the data team for the service around it. The risk shifts from too little process to too much: a scoping document that is a form to fill in, review boards that approve models nobody has watched run. Keep the ten questions and let the platform answer the engineering ones.

ARTEFACT Write the model scoping document ~60 MIN
YOU PRODUCEA model scoping document

Template

# Model scoping document: <name>
Author · Date · Version · Owner after launch

## Decision and action
Decision: <what is decided, by whom, by when>
Action when flagged: <hold / call / block>

## Cost of the two mistakes
Wrongly flagged (C): <cost, source>
Missed (L): <cost, source>
Break-even chance of the event: C / (C + L) = <figure>
Flags the reviewers can handle: <number per day or month>

## Labels
Count of positives · Source · Delay before a label arrives
Can a time split leave positives in the test period? <yes / no>

## Baseline
<rules or current process>, measured on <same data>: flags, caught, precision, with interval

## Features
| Feature | Source | Known when | Same code in training and serving? |
|---|---|---|---|

## Evaluation plan
Split · metric · interval · what result would change the recommendation

## Serving
Batch or online · when it runs · what it does · what it logs
If it is unavailable: <fail open or closed, and who decided>

## Rollout
Shadow period · acting period · how to turn it off

## Ownership
Owner · review rhythm · monitors · retrain or revisit trigger · exit criteria

## Recommendation
<rules / model / rules then model / vendor>, and what would change it
WORKED EXAMPLE

Ferrowave, nine weeks before the January payroll run. Adetoun, the data scientist, writes the document after the notebook scored an AUC of 0.97. All figures are illustrative.

Decision and action. Ferrowave’s customer success lead decides whether a batch runs. A flagged batch is held and the customer’s approver is called, in a window from 17:00 to 21:00 for batches due at 06:00 next day.

Cost of the two mistakes. A wrong hold costs twenty minutes of a reviewer at ₦7,500 an hour, so C is ₦2,500. A missed fraud costs ₦1.5m by finance’s estimate, so L is ₦1.5m. Break-even is 2,500 / 1,502,500, which is 0.17%. Reviewers can take about two holds a working day.

Labels. 32,400 batches in eighteen months, about 1,800 a month. That counts every batch from every customer, on-demand ones included, so it is far larger than the 31 scheduled batches that fall due on a busy 25th. Five are confirmed as fraud, each found when the customer wrote in. The last six months hold one positive, so a time split cannot measure a model.

Baseline. Rule 1, flag a batch when at least 15% of its lines and at least five payees are accounts first seen in the previous 24 hours: 486 flags (1.5%), four of five frauds caught, precision 0.8%, about 27 flags a month and nine hours of review. The 95% interval for four in five is roughly 28% to 99%. Rule 2 adds a total of at least 1.5 times the customer’s median and flags 131 batches, catching three. Both were tuned after reading the five cases, so treat the catch rates as optimistic.

Features. The notebook’s best feature, a payee’s number of batches over all time, is known only after the decision, so it is dropped. With it removed, the AUC falls from 0.97 to 0.71 on a random split.

Serving. Scored when a batch is submitted and again after any edit. A hold is placed by the hook Wolfgang builds in Payouts Core. If the check is unavailable, the batch runs and is queued for review the next morning; the customer success lead agrees this in writing.

Rollout. Four weeks in shadow, then Rule 1 holds batches with a one-step off switch. One unflagged batch in fifty goes to review.

Ownership. Adetoun owns the rule and reads the flags weekly. Revisit a model when there are thirty confirmed cases or review load passes capacity.

Recommendation. Ship Rule 1 now. A model is not measurable on five cases. Buying a vendor score would send payee account data to a third party before anyone has checked what the customer contracts allow.

Now you

The following February, Ferrowave’s pension customers raise a different worry: pensions paid to people who have died. You are Adetoun. Three pension-fund customers each send one monthly batch, so there are 72 batches in the last 24 months, with about 2,800, 4,100 and 6,200 payees. Month to month the payee lists barely change, so a “new account” rule would flag nothing. Two cases are confirmed, both found at the funds’ annual life-certificate checks, eight and eleven months after payments to a dead pensioner began. The batch file holds name, account, amount and nothing about age or status. A hold delays thousands of pensioners, and Ferrowave’s cost for a wrongly held batch is still about ₦2,500 of review time. Write the scoping document. It must say what signal the batch file does and does not contain, what the label delay does to a time split, and whether the first deliverable is a model.

Self-check

DECIDE

Nine weeks before the January payroll run at Ferrowave. You are Adetoun. The chief executive wants a flag live by then. Your notebook scores an AUC of 0.97 on a random split, with five confirmed fraudulent batches in 32,400 (every batch of every kind, about 1,800 a month) over eighteen months. One rule, new payees as a share of the file, catches four of the five and flags about 27 batches a month. Wolfgang in Payouts Core can build a hold hook in three weeks. What do you propose?

READING
  1. DOC
    Rules of Machine Learning: Best Practices for ML Engineering Martin Zinkevich, Google

    Practical rules for shipping a model. Read the section before machine learning, whose first rule is not to be afraid to launch without it, and the rules on training-serving skew.

  2. PAPER
    Hidden Technical Debt in Machine Learning Systems D. Sculley and colleagues, 2015

    The case for scoping the system around the model and for naming an owner. Read it before you promise a date. Read: The abstract and the opening sections, on how maintenance costs build up around a model.

  3. PAPER
    The ML Test Score: A Rubric for ML Production Readiness and Technical Debt Reduction 2017

    A checklist of 28 tests drawn from production experience. Use it as a review list for your own scoping document. Read: The abstract, then the lists of tests for data, model, infrastructure and monitoring.

  4. BOOK
    Designing Machine Learning Systems Chip Huyen, 2022

    Compares batch and online prediction and the ways of serving a model. Read it when you choose the serving shape. Read: Chapter 7, Model Deployment and Prediction Service.

  5. DOC
    MLOps: Continuous delivery and automation pipelines in machine learning Google Cloud

    Describes three levels from a manual, notebook-driven process to automated pipelines. Read it to judge how far your team needs to go.

All companies and people in these examples are fictional. Any resemblance to a real business or person is unintended.

RECALL CARDS Tap to flip. They join your review deck when you mark the lesson complete.
NEXT: Monitoring models and drift →