Python Conference APAC 2024

Deploy your Machine Learning model with Fast API
2024-10-25 , Workshop Class #1
Language: English

One of the challenges for a machine learning project is to deploy it. Fast API provides a fast and easy way to deploy a prototype with less software development expertise and yet allow it to be developed into a professional web service. We will look at how to do it.


In this workshop, we will go deeper into how to prototype a machine-learning project with Fast API. Fast API allows the creation API server with very little effort, it is easy to deploy a pre-trained model, but for models that require re-training, the challenge of when and how to retrain a model and update for a service in use becomes complicated. We will cover the aspect of delivering a pre-trained model and the design of re-training the model. This workshop will also provide suggestions for deploying the machine learning project so it can migrate from a prototype to a functional service in production.

Goal

The workshop aims to equip a data science team capability to convert their machine learning project into a prototype service using Fast API, at the end of the workshop, they will not just be able to deliver API calls to a pre-trained model, but they will also be able to design when to re-train and update the model and be ready to migrate the prototype into production.

Target audience

Data scientists who have little or no experience using Fast API or putting a machine learning model into production. This workshop will assume the audience already knows how to build and train a basic machine learning model (e.g. using Sci-kit learn).

Outline

Part 1 - Introduction to Fast APi and prediction on demand (25 mins)

  • Understand the basics of Fast API (5 mins)
  • Using a pre-trained model for prediction with API calls (10 mins)
  • Validating the query parameters (10 mins)

Part 2 - Re-train and update models (55 mins)

  • Background tasks (15 mins)
  • Lifespan events (15 mins)
  • Re-training with new data with Fast API (15 mins)
  • Problem with updating model: Race conditions (10 mins)

Part 3 - Machine learning model in production (10 mins)

  • Fast API in docker containers (10 mins)

After having a career in Data Scientist and Developer Relations, Cheuk dedicated her work to the open-source community and founded CMD Limes, a Python consultants cooperation. She has also co-founded Humble Data, a beginner Python workshop that has been happening around the world. She has served the EuroPython Society board for two years and is now a fellow and director of the Python Software Foundation.

This speaker also appears in: