Deploying an ML Model — ML Technical Interview Questions & Answers
Serving predictions via an API in production.
Deploying an ML Model
- Simple meaning: Deployment = other people (or an app) can get predictions. Save the model (and the scaler!) then serve: FastAPI / Flask endpoint, or a batch job every night.
- Picture: Notebook works on your laptop. Website sends hours JSON → API loads joblib file → returns P(fail). If you saved only the model and not the scaler, production numbers are garbage.
- Version the model file. Log inputs (carefully) and watch if live data drifts from train.
- Trap: pickle without the pipeline. Trap: training columns in a different order in production.
Technical Interview Tip: joblib the pipeline. API or batch. Same preprocessing as train.
Code Examples for Deploying an ML Model
Deploying an ML Model — working example
# PCA-style intuition: project 2D → 1D by a direction vector
points = [(1.0, 1.0), (2.0, 2.0), (3.0, 2.8)]
# unit direction along y = x
ux, uy = 0.7071, 0.7071
proj = [x * ux + y * uy for x, y in points]
print([round(v, 3) for v in proj])
# Tiny ensemble: average two model votes
votes = [1, 0, 1]
v2 = [1, 1, 1]
ens = [1 if a + b >= 2 else 0 for a, b in zip(v1, v2)]
print(ens)Deploying an ML Model — dim reduction compresses features; ensembles combine models; deep nets/RL/NLP are specialized families — practice the core math idea first.
How to Explain Deploying an ML Model to an Interviewer
What must you save besides weights?
Scaler / encoder Column list The pipeline
One serving style?
REST API Nightly batch