Building a model in a notebook is the easy part. Getting it into production — where it makes real decisions on real data, every day, without breaking — that's where most ML projects fail.
Data scientists say the "last mile" of ML is longer than the rest of the journey combined. Deployment, monitoring, and maintenance are what turn a prototype into a product. This module is about that last mile.
The most common deployment pattern: wrap your model in an API (Application Programming Interface). The finance system sends data, the API returns a prediction.
Common frameworks: FastAPI and Flask in Python. The API must be fast, reliable, and secure — it's making decisions on every transaction. It also needs authentication, rate limiting, and logging of every request.
Example: a loan application arrives → API receives applicant data → returns "probability of default: 4.2%." The bank's system uses that number for the decision.
Two main ways to score data with a model:
| Mode | When It Runs | Best For |
|---|---|---|
| 📦 Batch | On a schedule (e.g., nightly) | Monthly risk reports, end‑of‑day reconciliation |
| ⚡ Real‑time | The moment data arrives | Fraud checks, loan approvals, live pricing |
Batch is cheaper and simpler. Real‑time is more expensive but necessary when decisions need to happen now. Most finance systems need both.
Once a model is live, you must watch it like a hawk. Three things to monitor:
Performance: is accuracy holding up over time? Drift: are the input data distributions shifting? Data quality: are we getting unexpected nulls, outliers, or schema changes?
Set alerts. If accuracy drops 10%, or a feature suddenly changes distribution, the team should know immediately — not after monthly reports. Tools: Prometheus, Grafana, Evidently AI, Whylogs.
Six months from now, someone will ask: "why did the model behave differently in March?" You need to answer. That requires versioning everything: model weights, training data, code, hyperparameters, and environment.
Tools: MLflow, DVC, and Weights & Biases track models and experiments. Store every training run — not just the good ones. If a bug is found later, you need to trace it back to exactly which model was deployed when.
Financial models process personal and sensitive data. That makes them targets. Security isn't optional — it's the first requirement.
Essentials: HTTPS everywhere (encrypt traffic), authentication (API keys, OAuth), role‑based access (who can call the model, view its outputs, retrain it), and audit logs of every request. Store model artefacts in secure storage, not plain S3 buckets.
And never log personally identifiable information (PII) in plain text. A model log is a data breach waiting to happen.
In production, two things determine whether a model is viable: cost per prediction and latency per prediction. A beautiful model that takes 5 seconds and $1 per prediction is unusable for real‑time fraud detection.
Techniques: model quantization (smaller weights, faster inference), caching (reuse results for identical inputs), batching (score many at once), and model distillation (train a smaller model to mimic a big one). Balance accuracy, cost, and speed for each use case.
Design an API: Sketch an API for a loan model. What endpoint? What input fields? What output fields? What authentication? Write a simple request and response example in a notebook.
Batch vs. real-time: For three use cases (monthly cash flow reports, real‑time fraud checks, weekly credit portfolio reviews), decide which needs real‑time vs. batch scoring. Justify each choice in one sentence.
Monitoring plan: Create a one‑page monitoring plan for a credit model. What metrics to track (accuracy, precision, drift)? What alert thresholds? Who responds to alerts?
Versioning experiment: Pretend you have three model versions (v1, v2, v3). Design a versioning scheme: what do you version? How do you know which model made which decision? Sketch the log format.
Security checklist: List 5 security checks for a deployed financial model: authentication, encryption, logging, rate limiting, and access controls. For each, write one concrete example.
Cost/latency tradeoff: Two models: Model A is 5% more accurate but 10x slower and 5x more expensive. For real‑time card fraud, which would you pick? For monthly risk reports? Explain your reasoning.
By the end of this module, you'll be able to: deploy a model behind an API, choose batch vs. real‑time architecture, set up monitoring for drift and performance, version models reproducibly, secure deployments, and balance accuracy against cost and latency.