A well-trained machine learning model can make a web or mobile app smart enough to predict future actions and deliver content as per user interest. It can show what a user like to buy or read about. This all needs heavy computation and low latency. So we deploy our trained models as a web service on a cloud server and then consume it via a REST API.
In this tutorial, we’ll deploy a trained model as a web service on the Microsoft Azure cloud server and will consume it using web API.
Build Model
We have a separate post for Building Machine Learning Models in Microsoft Azure which is a hands-on guide to build the model using a drag-n-drop interface on the Microsoft azure ml studio.
Deploy Model
Once you have run the model successfully and achieved a good accuracy score, It’s time to deploy the model on a cloud server so we can use it in our web or mobile application.
Go to the Microsoft Azure Machine Learning portal and log in with your credentials. Go to the Experiments page in the main menu and click on your experiment name to open the experiment.
The next step is to convert this experiment into a predictive web service. Go to the bottom of the middle section and mouseover on Set up Web Service and select Predictive Web Service [Recommanded]
Trained model will be saved as a predictive experiment and will be opened in a new tab. Here web service input and web service output module will be added automatically. Click on the Run button at the bottom to run the experiment.
The final step is to deploy it as a web service. Go to the bottom of the middle section and mouseover on Deploy Web Service and select Deploy Web Service [Classic]
And your model has been deployed as a web service. An API key is generated and shown on the web service detailed page.
Use Predictive Model
An API HELP PAGE is available on the web service to consume the web service. The Documentation to use our web service is automatically created by ml studio and it makes our job very easy. Click on the Request/Response link at the bottom of the page. And you’ll see complete documentation with example source code.
You can run python script locally or use a kaggle notebook to call the web service and get the response in JSON format. For web applications, You can use jquery to send ajax request to fetch the result. And for Mobile application, use REST API modules to call the web service and get a response.