Check out our Ultimate Guide to DataOps!

Download now!

How to deploy a Machine Learning model?

This article invites you on a short tour of how to go from exploration to production when working with Machine Learning models. What are the major stages of ML models life cycle? In the last part of the article, we will show an example of architecture based on Docker compose and hosted in the cloud to deploy your ML model.

Part 1: Go from exploration to production

Every use case in data science is a small journey that requires often moving from an unclear operational problem to a formal and precise response. This response will have real impacts on the daily lives of employees or customers.

From the beginning, this journey will challenge you “to get off the beaten track” because it is a new and fast-evolving field, and there are few standards available. It is quite rare that a successful practice or technology implemented by one company will produce the same benefits for another simply by purchasing the same technologies.

Machine learning projects face uncertainty at every step, from use case identification to delivery, so stay open to new approaches with a view to progressive scale-up.

If you are reading this article, it probably means you are looking for ways to push your model one step further. The roadbook in this article is composed of three main stages with resting points between to decide whatever to pursue the journey or not.

Stage 1. Proof of concept (POC)

Your starting point is to clearly define what is the output and outcome of your ML project. The output will be what your model will be predicting. The outcome is the purpose of why you do what you do.

During this stage, you frame business need and develop first ML models to qualify data. Ideally, you also evaluate the expected business gain and associated return on investment. Easy to say but hard to do.

Note: Identify the area of benefits that use cases will target (revenue growth or cost reduction) and estimate a range of potential EBITDA.

At the end of this stage, you come up with a freshly created and validated Proof Of Concept.

Stage 2. Prototyping

If your models are conclusive and business people are confident about the results, you can go ahead to frame a functional pilot in collaboration with IT teams. The purpose is now to qualify functionally and technically your use case. To do so, you start with:

  • Defining your target architecture;
  • Connecting to data sources;
  • Automating data treatment and execution;
  • Deploying a monitoring system.

The idea behind this stage is to develop a real application rapidly to collect users feedback and prepare for industrialisation.

At the end of this stage, you dispose of an operational and partially automated prototype of your future ML application. From now, you are ready to hand over the lead responsibility to your IT teams. But before that, you need to clean, package and prepare the code for industrialisation.

Stage 3. Packaging and preparing industrialization

To package the code, you need to address two main questions:

Question 1. What types of technology to deploy your functional pilot?

Question 2. What kind of methods to deliver the code?

Question 1. In terms of technological environment, there are different points to address:

  •   Programming language: for application and functional development. For example, what language to use for automating data acquisition, exploration and prediction?
  •   Infrastructure: Cloud or not, private, hybrid or public?
  •   Open source technology: accepted or forbidden? For example, for dashboarding, system monitoring, etc.

 

Question 2. Regarding the methods to deliver the code, you might decide on:

  •   Code versioning,
  •   Model deployment options,
  •   Continuous integration / Continuous delivery (CI/CD),
  •   Tests strategy: unit, acceptance, integration.

One done, it will be time to deal with the automation of processing and monitoring of the whole data pipeline from extraction to exposure. Usually, this part is handled by IT teams in large organisations.

Part 2: Example of architecture based on Docker compose and hosted in the cloud.

Before showing an example of architecture to deploy your ML prototype, we will precise what is Docker compose and its characteristics. In the previous article, we covered the basics of Docker.

Just a short reminder:

Docker is an application container tool. A container is a sort of virtual machine that executes an application in a dedicated environment.

Quite often, to execute your ML application, you need to run many different applications. This is where Docker compose plays an important role. 

Docker-compose is a container orchestrator. It allows us to launch an architecture made of services inside containers.

Now, we come back to our case study and set out the following below framework:

  • Python for application and functional development:
  • Infrastructure in the cloud (ex. AWS)
  • Some open-source technology (ex. Grafana SuperSet, Airflow)
  • Git for code versioning
  • Docker for deployment
  • Jenkins for CI/CD.

As we can see above, infrastructure hosted in the cloud includes storage and compute capabilities. Raw and processed data with predictions will be stored on a storage instance. All processing treatment is executed on a compute instance. The compute instance also provides access to expose ports and endpoints for other applications to consume the stored data.

Behind the “other applications”, you find dashboarding, monitoring, Jupiter Lab for interactive computing in Python and, etc.

To facilitate deployment, it is beneficial to use Docker containers to package each application with its dependencies and Docker compose to orchestrate all containers

 

 

There are tons of other possible architectures and technological environment you might choose to deploy your ML models. Remember, one size does not fit all. Be creative.

We hope you appreciated this article and got inspired to put your ML model into production to make it useful for clients or internal employees! 

 



Can we use some cookies?

This site uses cookies. An explanation of their purpose can be found below. To comply with new EU regulation, please confirm your consent to their use by clicking "Accept". After consenting, you will not see this message again.

Know more about tracers