---
title: "How do you deploy a machine learning model?"  
description: "How do you deploy a machine learning model?"  
author: "Ravi Vishwakarma"  
published: 2026-03-11  
updated: 2026-04-15  
canonical: https://answers.mindstick.com/qa/116401/how-do-you-deploy-a-machine-learning-model  
category: "artificial-intelligence"  
tags: ["artificial intelligence"]  
reading_time: 2 minutes  

---

# How do you deploy a machine learning model?

## Answers

### Answer by Anubhav Sharma

Deploying a [machine learning](https://www.mindstick.com/articles/44690/how-shopping-is-evolving-with-machine-learning) (ML) model means making it available so real users or systems can send data to it and get predictions. Think of it as moving from “training in your laptop” to “running in [production](https://www.mindstick.com/news/2276/by-the-end-of-2023-tesla-cybertruck-mass-production-will-begin).”

Here’s a clear, practical flow:

## 1. Train and Save the Model

You first build and train your model using tools like scikit-learn, TensorFlow, or PyTorch.

Then save it:

- `.pkl` / `.joblib` (scikit-learn)
- `.h5` or SavedModel (TensorFlow)
- `.pt` (PyTorch)

## 2. Wrap the Model in an API

You expose the model using a [web API](https://www.mindstick.com/blog/369/introduction-to-the-asp-dot-net-web-api) so other apps can call it.

Common frameworks:

- Flask (simple)
- FastAPI (fast & production-ready)

Example flow:

- Input → API → Model → Prediction → Response (JSON)

## 3. Containerize (Optional but Recommended)

Use Docker to package:

- Code
- Model
- Dependencies

This ensures it runs the same everywhere.

## 4. Choose Deployment Type

### A. [Cloud](https://www.mindstick.com/services/cloud-development) Deployment

Popular platforms:

- [Amazon Web Services](https://www.mindstick.com/articles/290104/5-advantages-of-amazon-web-services-aws) (EC2, SageMaker)
- [Google Cloud](https://www.mindstick.com/news/477/wipro-is-now-a-google-cloud-partner-with-a-focus-on-application-growth) Platform (Vertex [AI](https://www.mindstick.com/services/artificial-intelligence))
- [Microsoft Azure](https://www.mindstick.com/articles/198746/things-you-should-know-about-microsoft-azure-as-a-cloud-developer) (Azure ML)

### B. Server-based Deployment

- Host API on a VM (Linux server)
- Use Nginx + Gunicorn for production

### C. Serverless Deployment

- AWS Lambda / Azure Functions
- Good for low-traffic or event-based predictions

### D. Edge / On-device

- Convert model (e.g., TensorFlow Lite) for mobile or IoT

## 5. Handle Scaling & Performance

- Use [load balancers](https://www.mindstick.com/articles/337429/explain-load-balancers-in-web-applications-and-improving-reliability)
- Add caching (e.g., Redis)
- Batch predictions if needed

## 6. Monitor & Maintain

Track:

- Model accuracy (drift)
- Latency
- Errors

Tools:

- Logging systems
- Monitoring dashboards

## 7. CI/CD Pipeline (Advanced)

Automate:

- Model retraining
- Testing
- [Deployment](https://www.mindstick.com/articles/325966/process-of-application-development-and-deployment)

## Simple Real-World Architecture

```plaintext
User → Frontend → API (FastAPI/Flask)
                    ↓
                 ML Model
                    ↓
               Prediction
```

## Quick Example (FastAPI)

```python
from fastapi import FastAPI
import joblib

app = FastAPI()
model = joblib.load("model.pkl")

@app.get("/")
def home():
    return {"message": "ML API running"}

@app.post("/predict")
def predict(data: dict):
    prediction = model.predict([data["input"]])
    return {"result": prediction.tolist()}
```

## In Short

- Deployment =\ **Model + API + Hosting + Scaling + Monitoring**


---

Original Source: https://answers.mindstick.com/qa/116401/how-do-you-deploy-a-machine-learning-model

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
