Azure Machine Learning Web Service

Damir Dobric Posts

Next talks:

 

    

Follow me on Twitter: #ddobric



 

 

Archives

 

Publishing Trained models as Web Service is probably very interesting and powerful feature of ML in many scenarios. I already blogged about this few weeks ago. This post focuses some improvements in publishing process. Notre that there are also many scenarios which cannot leverage ML as Web Service because of various reasons. For example your application is running On-Prem and has not internet connection. Sometimes some of killer arguments is bad performance of Web Service. If your application is working real-time consuming of Web Service will not be the way to go. Unfortunately, there is no out-of-the-box option for you to download trained model and run it locally as API. Personally I would consider this feature are very important especially in solutions which target Industry 4.0 initiative.

After your model is trained, it is a time to publish it as a Web Service. To start with this process click on “Publish Web Service”.

image

This “click” will guide you through the process of publishing, which is shown on following slides.

imageimage

 

image image

 

image

In fact  you don’t have to do anything. Just follow comments. After all save this model and run it.
Before the experiment is published as a service, some optimization has to be done. In other words, experiment will mostly contain many modules (shapes), which are not required by service. For example, evaluate is not needed after you trained the model. If you tale a look on my experiment above I used two modules for training. To publish a result as Web Service I do need one best module only. I open the evaluation results which helps me to chose the best model.
image

image What I get, it is following ROC - Receiver Operator Characteristic Curve. This curve shows the fraction of true positives out of the total actual positives.
As you see, my red one represents the perfect model. You might thing this is demo-case, but believe me I spend bunch of time to find that model.
It is in this case Two-Class Boosted Decision Tree.
It predicts a mathematical function             

               predicted value = int(mod(x,10), 5)

When learning/probing a new algorithm I use to train a data which has a known mathematical function.

So, I chose that model and remove another one (blue one). Now my experiment looks like:

image


This is my starting point now, when I want to publish it as a Web Service. To do this, there is a new operation called “Create Scoring Experiment”. Click on the button

image 
and new experiment will be created. This is how my score experiment looks like:

image

Run this experiment and not that this will be quickly finished, because model is already trained. Now you can publish it as a Web Service by clicking on the button “Publish Web Service”. After successful publishing browser will navigate you to the Web Service Page.

image

If you navigate now to API help page you will see following.

image

This represents a sample request which will be send to the Web Service. This contract is not really best contract as it would be expected in service oriented architecture, because two values in blue frame represent the values which are not needed as input. outa+b+c is value which was used as score to train the model. Value Column 4 was not used in training at all. I didn’t show this in data source in this post, because it is out of scope of this post. But publishing process always takes all as input.
It is not nice from architecture point of view, but it works. The same design principal was used for response.

Response contains the actual result as “Scored Labels” and “Scored Probabilities”, but it also contains all of your input. It is very unusual, but again, it works.

image

To test the model simply click on test, enter A, B, C or whatever your features.

image

Click on a checkbox-button and wait a bit.

image

And, here is the result:

image
I enter now some other values and get following result:

image

Now if you know the mathematical function ( remember predicted value = int(mod(x,10), 5)) you can check if the result is correct.


Posted Apr 21 2015, 07:54 AM by Damir Dobric
Filed under: , ,
developers.de is a .Net Community Blog powered by daenet GmbH.