Make an API for trains

October 14, 2015


Report Abuse
Creating an application programming interface (API) is easy in Azure ML Studio. Here is a step-by-step example for how to turn a model into a web service
The fun part of data science is making models. Turning those models into something that can be built into a web page or analytics code can be tough to do well. Luckily, Azure ML makes this process easy. This example steps you through how to do this in the Studio. 1. We start with a model that shows [feature engineering for train speed prediction][1]. If you open this in Studio, these instructions will walk you through how to publish it as a web service. 2. Select the "Train Model" module in the right hand column. This is the one that gave the best results of the three. Then click the "Set Up Web Service" button. This will collapse the experiment, which trains the model, to a scoring experiment. A scoring experiment will make predictions about new data points, but it won't modify the original model. ![set up web service button][2] 3. Click the "Deploy Web Service" button. You're done. This is all you need to do to create the web service. ![deploy web service button][3] 4. To use the deployed model in an application, you just need two pieces of information: the API key and a URL. The API key is prominently displayed on the API dashboard page that pops up when you deploy your web service. Anyone who has this key can call your web service, so don't pass it around to anyone unless you want to pay for them to use it. ![API key][4] 5. There are two URLs associated with the API, one for the Request/Response Service (RRS) and one for the Batch Execution Service (BES). The RRS makes predictions about one data point at a time. With BES, you provide a file full of data points, one per row, and the service makes predictions for the entire batch at one pass. If you have a lot of data points to get predictions for BES is a much faster and cheaper way to go. To find the URL for the RRS, click the "Request/Response" link. ![request response link][5] 6. The URL is displayed prominently. You can find the URL for the BES the same way. Both use the same API key. ![URL][6] If you go back and change your original model and deploy it again, the API key and URLs don't change. This allows to make changes to your original model after putting it out into the world. It's also good to keep in mind that if you are using someone else's web service, they can change what it does at any time with no warning. Make sure you trust the publisher. 7. Now you're ready to write an application that calls your model. Or better yet, bribe a web developer or software engineer friend to write one for you. Then you can spend your time building more models. This example is one of four that I talk about in a presentation called The Other Stuff: Getting from Machine Learning to Data Science. The rest of the examples from The Other Stuff are in [this collection][7], including [data visualization][8], [feature engineering][9], and [handling missing values][10]. If you found this helpful please take a look at [my other submissions][11] to the Cortana Analytics Gallery and [follow me on Twitter][12]. links to this page. I am a Senior Data Scientist at Microsoft. [1]: [2]: [3]: [4]: [5]: [6]: [7]: [8]: [9]: [10]: [11]: [12]: