How to Deploy Machine Learning Models with FastAPI, Docker, and Fly.io | End-to-End Tutorial

Опубликовано: 07 Май 2026
на канале: DataTalksClub ⬛
7,929
246

In this workshop, Alexey Grigorev, founder of DataTalks.Club and instructor of the Machine Learning Zoomcamp, walks through the practical steps of turning a trained machine learning model into a production-ready web service, focusing on modern deployment tools like FastAPI, UV, Docker, and Fly.io.

You'll learn about:

✅ Transitioning from Jupyter notebooks to production-grade Python scripts
✅ Building an API for model inference using FastAPI
✅ Validating input and output data with Pydantic
✅ Managing dependencies efficiently with UV virtual environments
✅ Containerizing machine learning apps with Docker
✅ Deploying your app to the cloud using Fly.io
✅ Best practices for lightweight and reproducible ML environments

This workshop is ideal for data scientists, ML engineers, and backend developers who want to understand the full path from a trained model to a deployed API.

🔗 Resources
ML Zoomcamp course: https://github.com/DataTalksClub/mach...
Code for this workshop: https://github.com/alexeygrigorev/wor...
Module 5 of ML Zoomcamp: https://github.com/DataTalksClub/mach...

Timecodes:
0:00 Course overview and Machine Learning Zoomcamp updates introducing the Machine Learning Engineering module
1:10 Deep dive into Machine Learning Engineering focusing on Module 5: Model Deployment
2:04 Workshop purpose explained updating the module with new tools and libraries
3:14 FastAPI introduction as the preferred framework over Flask for building ML web services
3:48 UV introduction as a faster modern alternative to pipenv for dependency management
4:34 Cloud deployment plan using Fly.io instead of AWS Elastic Beanstalk
5:06 Environment setup demonstration using GitHub Codespaces and Jupyter
9:05 Installing Jupyter Notebook with pip install jupyter command
14:17 Training the churn prediction model using logistic regression
20:33 Saving and loading the trained ML model with pickle
26:23 Improving workflow with scikit-learn pipeline combining DictVectorizer and logistic regression
29:01 Converting Jupyter Notebook to Python scripts for production readiness
36:01 Building a FastAPI web service for churn prediction inference
41:56 Demonstrating FastAPI built-in API documentation with OpenAPI and Swagger UI
51:39 Creating a marketing client script using Python requests library to call the prediction API
56:06 Implementing input validation and schema enforcement with Pydantic in FastAPI
1:05:29 Isolating project dependencies using UV virtual environment
1:12:45 Containerizing the FastAPI application with Docker and creating a Dockerfile
1:25:24 Optimizing Docker image size using slim bookworm base and updated UV setup
1:28:50 Deploying the Dockerized machine learning app to Fly.io

Connect with DataTalks.Club:
Join the community - https://datatalks.club/slack.html
Subscribe to our Google calendar to have all our events in your calendar - https://calendar.google.com/calendar/...
Check other upcoming events - https://lu.ma/dtc-events
GitHub: https://github.com/DataTalksClub
LinkedIn -   / datatalks-club  
Twitter -   / datatalksclub  
Website - https://datatalks.club/

Connect with Alexey
Twitter -   / al_grigor  
Linkedin -   / agrigorev  

👋🏼 Support/inquiries
If you want to support our community, use this link - https://github.com/sponsors/alexeygri...

If you’re a company, reach us at [email protected]

#MachineLearning #FastAPI #Docker #MLOps #ModelDeployment #Flyio #DataTalksClub #MLZoomcamp