4 Ways to Productionize Your Machine Learning Models

Artificial Intelligence which includes Machine learning,Deep Learning,etc has changed the world and it is going to continue to change our lives.

As we begin to accumulate more data via the smart technologies we used, there is going to be a huge demand for storage of these data. But that is not all, there is also going to be the demand for deriving insight from the data collected and stored.

This brings us to the concept of data science which can be easily summarized as either

  • Descriptive Analytics: what does the data mean? what does it tell us?
  • Predictive Analytics: what pattern can we see in the data and how can we use it to foretell the future?
  • Prescriptive Analytics: how can we use the prediction and the insight derived from the data for making decisions.

As a Data Worker ( anyone that works with data such as a data scientist,data engineer,ML engineer,statistician,BI,etc) you will need to understand your data and be able to build models.

Most people end at building the ML models. And that is it. But for your end-user to benefit from your model, you will need to productionize and deploy it.

Productionizing Your ML Models

There are many ways you can productionize your model, but we will discuss the four main ways you can productionize your ML Model.

  1. Embedding Your ML Model into a Web App
  2. Using  your ML Model as an API
  3. Using your ML Model as a Package
  4. Using Streamlit

Embedding Your ML Models into a Web App

This method involves embedding your machine learning model into a web application. The most commonest web applications mostly used include flask,express,django and the like. This requires you to learn web development to build a user-friendly interface. At least you should be able to know some basic html and css to get your model productionized.  Flask makes it easier due to it light weight and easy learning curve to productionize your model and then deploy via the various platforms.

So you can then deploy your ML web app on GCP,AWS,Azure and Heroku.

Here is a video of how to embed the model in flask

Using Your ML Model as an API

The next method is similar to the first ,but in this case you are relying on a REST approach. You are utilizing an API to act as a bridge. This method is quite useful , since you can expose your ML model to several devices and technologies. Users with mobile phones can benefit from your model since it is being exposed as an API. Others can also use your API in their own web applications.

Using Your ML Model as a Package

This is the less know method. It involves saving your models and utilizing it as a package or a library. Popular python libraries such as SpaCy,Gensim and Textblob use this approach. For example when you a using spacy for named -entity extraction or using textblob for sentiment analysis, you are actually using their pre-trained machine learning model to do that task.

This explains why you have to download the model after install spacy in the case of spacy.

This has a lot of advantages.

Using Streamlit

The final and the most recent method for productionizing your model is to use Streamlit. Streamlit is a machine learning framework that is useful for building ML tools. It comes as a package and a CLI. With streamlit you simply convert your python code and your machine learning models into production ready interface without learning html or css.

It is quite awesome. With little code you can spin up a production ready machine learning app.

You can check out this video to see how it works.

These are the main ways you can convert your ML models into products that the end-user as well as others can benefit without having to learning coding.

To learn more about how to build ML Web Apps using these four methods, you can check out this course.

 

Video

Thanks For Your Time. Stay blessed

Jesus Saves

By Jesse E. Agbe (JCharis)

 

 

Leave a Comment

Your email address will not be published. Required fields are marked *