Introduction To AZURE ML - Creating An Azure ML Web Service And A Client Application - Part One

Artificial Intelligence (AI) has been a fascinating concept of science fiction for decades, but many researchers think we’re finally getting close to making AI a reality. Google CEO Sundar Pichai noted during his keynote segment in Google I/O that the company is moving from being a mobile first company to an AI first one. Microsoft is essentially on the same path, even as its CEO Satya Nadella phrased it differently.

Machine learning is the modern science of finding patterns and making predictions from data based on different situations. Some argue it's same as AI but it's not it's not but it's proving to be most successful approach to the AI.

The world is being reshaped by machine learning and we no longer need to teach computers how to perform complex tasks. To stay ahead, we should learn to build systems that let them learn how to do it themselves.

AZURE ML Studio is a recognized game changer in applying the power of the cloud to solve the problem of big data processing. It offers a simple and intuitive framework to develop machine learning and Data Science applications, and has an easy to use graphical interface that allows you to quickly develop machine learning apps.This is more of a big picture way of putting an entire simple machine learning pipeline together without having to actually write any code. Moreover, it empowers "normal" developers to approach the world of data science without a deep mathematical background, which actually makes the whole process easier even for experienced programmers.

The topic is divided into two articles. First part will explain how to import a data set into Azure ML Studio and use that to create an experiment that will be used to publish as a web service.

Prerequisites

  • AZURE ML account
  • Visual Studio

Let's get started.

  • Open Azure ML Studio and sign in using your Azure ML account.

  • Select the Datasets icon on the left nav bar of Azure ML Studio home page.

    Azure

  • Click "New" on lower left corner to upload the dataset. Choose dataset and then select "From Local File". Locate the file that you had just downloaded and upload it by selecting the tick mark on the lower right corner.

    Azure

  • Next, click on "Experiments" on the nav bar and select "Blank Experiment".

  • Expand the Dataset folder and drag and drop the data set that we had just added (here ‘Building.csv’’).

  • Expand the data transformation category and drag and drop ‘Split Data’ into the designer surface. Split data is used to divide data into two sets mostly used when you need to split the data into training and testing sets

  • Also, set a fraction of rows in the first output dataset to 0.7 to split the data at 70/30 i.e 70% for training and 30% for testing.

    Azure

  • Expand the Machine Learning category, then Initialize Model, and finally Regression. Locate the "Decision Forest Regression" entry and drag it onto the designer surface. Also, drag and drop Score Model from Score subcategory, Train Model from Train category, and the Evaluate Model from Evaluate subcateogry. Now, the designer window should look like the one shown in fig.

    Azure

Decision Forest Regression

This is used to create a regression model (regression analysis is a statical process of estimating relationship among the variales.It is done traversing and analysing sets of data where the focus is on dependent and independent variables) using a collection of decision trees. After you configure the model, you must train it using Train model.

Train Model

It is used to train a classification or regression model in a supervised method. That means you must provide the historical data to train model, and the data must contain predicted outcome (result) and the dependent variables.

Score Model

It is used to generate predictions using a trained classification or regression model. The predicted value depends on the Training model and input data set.

If it's Regression model, the Score model generate a predicted numeric value.

Evaluate Model

It is used to measure the accuracy. It inputs a dataset containing scores generated from a model and the Evaluate Model module computes a set a standard metrics.

The standard model returned depends on the type of model that you evaluate.

  • Select the Train Model operation. Click the Launch Column Selector in the right pane of ML Studio. Click the With Rules entry and in the empty column list select the Wall Area column name(dependent variable).

    Azure

  • Make the following connection.

Decision Forest Regression operation to the remaining input of the Train Model operation.
Second output of the Split Data operation to the Score Model operation.
Output of the Score Model operation to the left input of the Evaluate Model operation.
Output of the Train Model operation to the remaining Score Model input.

The final figure should be somewhat similar to the following.

Azure

  • Run the experiment by clicking Run button on the bottom of the designer window. When the experiment run successfully (Green check marks in operation boxes) , save your experiment with a name of your choice.

    Azure

    Azure

It's time to deploy web service now.

  • Go to Experiments from Azure ML home page. Select the Experiment that we had saved before. Depending on the state of the web service you may not have to run it again. If it did not show green checks in different stages, you have to run it again.

  • Select "Setup Web Service" button in the button bar at the bottom of the designer. Then, select Predictive Web Service [Recommended]. Now, you should see Web Service Input and Web Service Output in the designer window.

    Azure

  • Before you can deploy the Web Service, you have to Run it again. Click "Run" button and wait till it runs successfully with green check mark on the Score Model.

  • Now, you are all set to deploy the Web Service. Click the "Deploy Web Service" button. Azure ML Studio begins the creation of web service and opens the following screen indicating success. The API key has been removed from this image but you will have an API key present in your web service.

    Azure

To test theWeb Service that we had created, click the "Test" button to open the data entry dialog.

Enter the following values in the data entry dialog (these values are taken from the training model data).

  • 250 for wall area
  • 110.25 for roof area
  • 8 for overall height
  • 0 for glazing area
  • 14.55 for heating load

Click the check mark in the bottom right corner of the data entry dialog.

Look at the status bar for the output. You can also click the "Details" button to see an example of the returned JSON.

In the next part of this article, I will describe how to create a client side application to invoke the Web Service that we have created.

Note - I have uploaded the data file with this article (Building.csv) if you want to give it a shot.

For information regarding Azure ML, please refer here.