How would you deploy a trained scikit-learn model as a REST API?
What the interviewer wants to hear
- Save model artifact and load once at startup
- Web framework endpoint with input validation
- Package in Docker with pinned dependencies
- Health checks, logging, metrics
- Deploy to a platform with scaling
Model answer
I save the trained model, ideally as a full pipeline including preprocessing, and register it. Then I write a small service with a framework like FastAPI that loads the model once at startup, not on every request. A predict endpoint accepts JSON, validates it with a schema so wrong types or missing fields return a clear error, runs the model and returns predictions. I add a health endpoint for readiness and liveness checks, structured logging of inputs and outputs (with sensitive data removed), and metrics like request count, latency and errors. I package it in a Docker image with pinned versions, the same ones used during training. Finally I deploy it to Kubernetes or a managed container service with autoscaling, run a load test, and add monitoring dashboards and alerts.
Can you answer it under time pressure?
Take a timed easy round and get scored on every answer.
More easy MLOps Engineer questions
- What is MLOps, and how is it different from traditional DevOps?
- Why does a team need a model registry? What information should it store?
- How do you make a model training run reproducible?
- What would you monitor for a model running in production?
- What is training-serving skew, and how do you prevent it?
- How do you decide between batch predictions and a real-time model API?
- Explain the difference between data drift and concept drift, and how you would detect each.
- What makes a good Docker image for a model-serving service?
- Which Kubernetes concepts matter most when you deploy a model service, and why?