Think Build Implement Repeat
London, UK +44 7367 067226
WhatsApp FOLLOW f in X
  1. Home
  2. Blog
  3. From Notebook to Running Service
Python & Django

From Notebook to Running Service

Putting a Python machine learning model into production: versioning, drift monitoring, feature consistency, retraining and a fallback when it goes down.

Updated 2 min readBy SpiderHunts Technologies

Free estimateNo obligation

Get a free estimate

Tell us what you need. A senior engineer reads every enquiry.

Takes under a minute. We never share your details.

  • Free consultation
  • No commitment
  • NDA on request

Prefer to talk? Book a free 30-minute call →

Quick answer — TL;DR

A model in a notebook is a demonstration. Production needs versioning, monitoring for drift, a defined retraining process and a fallback for when the model is unavailable.

The notebook is the easy part

Training a model that performs well on historical data is a well-understood exercise. Running it as a dependable component of a business system is a different discipline entirely.

The gap between a promising notebook and a reliable service is where most business machine learning projects stall, and it is almost entirely engineering rather than data science.

What production requires

  1. Versioned models, with the training data and code recorded
  2. Reproducible predictions — the same input gives the same output
  3. Input validation, because production data differs from training data
  4. Monitoring for drift in inputs and in outputs
  5. A fallback for when the model is unavailable or unconfident

Drift is the thing that catches people

A model trained on last year's data becomes less accurate as the world changes. Nothing errors; the predictions simply get worse, and nobody notices until someone questions a result.

  • Monitor the distribution of inputs against training data
  • Monitor the distribution of predictions
  • Track accuracy against actual outcomes where they become known
  • Set a retraining trigger and a schedule

Feature consistency

The features computed at prediction time must match those computed at training time exactly. Divergence between the two is one of the most common and most subtle production failures.

Share the feature computation code between training and serving rather than reimplementing it.

Be honest about whether it is needed

ProblemFrequently better solved by
Classification with clear rulesRules
Small data volumeHuman judgement
Forecasting stable seasonalityStatistical methods
Text understandingA language model, not custom training
Genuine pattern recognition at volumeMachine learning

A great deal of what is proposed as machine learning is better solved by simpler methods, and we say so reasonably often.

FAQ

Frequently asked questions

The questions readers ask us after this guide.

Still have a question?

Ask us directly — a senior engineer will get back to you.

Ask about your project

How much data do we need?

It depends entirely on the problem. Thousands of examples for simple classification; considerably more for anything nuanced.

How often should models be retrained?

When drift monitoring indicates it, or on a schedule if the domain changes steadily. Not never, which is the common default.

Do we need a data scientist?

For custom model training, probably. For most business AI, which is retrieval and language models, no.

What if the model is wrong?

Confidence thresholds and a human path, as with any AI system. A model with no fallback is a single point of failure.

Keep reading

More on Python & Django

Python & Django

An API Other Systems Can Depend On

Designing a Python API service others can depend on: validation at the boundary, consistent errors and status codes, early versioning and documentation.

Python & Django

Moving and Transforming Data Reliably

Building data pipelines in Python that cope with malformed input: restartable stages, quarantining failures, reconciling counts and alerting on absence.

Start here

Model that works in a notebook?

Production is a different piece of work. Happy to scope what would be needed.

  1. You tell us what you needTwo minutes on the form, or a message on WhatsApp.
  2. A senior engineer reviews itAnd comes back with questions, a realistic range and an honest view on fit.
  3. Free 30-minute scoping callWe talk through scope, options and a realistic estimate — with no obligation.
Free estimateNo obligation

Talk to someone who builds this

Send a short brief and we will come back with an honest view and a realistic range.

Takes under a minute. We never share your details.

  • Free consultation
  • No commitment
  • NDA on request

Prefer to talk? Book a free 30-minute call →