Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the best way to build and expose a Machine Learning model REST api?

I have been working on designing REST api using springframework and deploying them on web servers like Tomcat. I have also worked on building Machine Learning model and use the model to make prediction using sklearn in Python. Now I have a use case where in I want to expose a REST api which builds Machine Learning Model, and another REST api which makes the prediction. What architecture should help me to achieve the same. (An example of the same maybe a Amazon Machine Learning. They have exposed REST api for generating model and making prediction)

I searched round the internet and found following ways:

  1. Write the whole thing in Java - ML model + REST api
  2. Write the whole thing in Python - ML model + REST api

But playing around with Machine Learning, its models and predictions is really easier and more supported in python with libraries like sklearn, rather than Java. I would really like to use python for Machine Learning part.

I was thinking about and approach wherein I write REST api using JAVA but use sub-process to make python ML calls. Will that work?

Can someone help me regarding the probable architectural approaches that I can take. Also please suggest the most feasible solution.

Thanks in advance.

like image 374
harshlal028 Avatar asked Mar 10 '23 22:03

harshlal028


1 Answers

As others mentioned,

  1. using AzureML is easy solution to deploy ML model as web service/ rest service. However, you need to build the model in Azure platform using graphical interface (drag and drop, configure). People may not like this approach if they have used python -sklearn code build a model. Though, AzureML has option to include R and python script, i did not like it much.

  2. Another option is to store the python ML model as .pkl file and using Flask / DJango rest framework, deploy the model. client apps can consume the rest service. Here is an excellent tutorial on youtube. https://www.youtube.com/watch?v=s-i6nzXQF3g

like image 117
Ramesh Gowda Avatar answered Apr 26 '23 23:04

Ramesh Gowda