Dinesh Asanka
After publishing the model.

Prediction in Azure Machine Learning

July 16, 2020 by

Introduction

After discussing the basic features of Azure Machine Learning and how to clean the data from Azure Machine Learning, let us look at how to perform prediction in Azure Machine Learning. Prediction is one of the important aspects of Machine Learning as it will help to make strategic decisions.

Data Selection and Data Cleaning

Like we did in the last two articles, let us quickly select a data source, Bike Buyer, and apply the normalization if needed after choosing only the relevant columns as shown in the below screenshot.

Setting up with a data set in Azure Machine Learning.

In the above configuration, columns such as addresses, names, keys, and attributes with different languages other than English were removed. These columns were ignored to improve the Prediction in Azure Machine Learning as those columns do not make major contributions towards buying a bike. For example, a customer’s name and address will not make any contributions towards a bike buyer.

Data Split

In most of the Machine Learning techniques, we need to have two datasets, Training and Testing datasets. The training dataset is used to build the model while the Testing dataset is used to evaluate the trained model. Though there are different techniques available for data splitting, like SQL Server, in Azure Machine Learning, the percentage split is the available technique to split the data. In this technique, random data of a given percentage will be split to train and test data.

Under Data Transformation -> Sample & Split, there is a control called Split Data. It is configured as shown in the below screenshot.

Including the Split Data control.

The following are the settings for the Split Data in Prediction in Azure Machine Learning.

Configuration of Split data control.

As shown in the above configuration, the train dataset is 0.7 from the dataset. Further, it is a random split and data will be split randomly to train and test dataset. When the Stratified split is set to true, data is split in such a way that both training and testing dataset has almost the same sample percentage of data for the selected column. In this configuration, training data will have 70% of the data with bike buyer yes and no values. When the stratified split is set to true, you need to choose the relevant attribute which is BikeBuyer.

It is should be noted that there are two outputs in the Data Split control where the first one is the training dataset and the second one is the testing data set.

The Training Model

Training is an important aspect of prediction. You can find the Training Model control by navigating Machine Learning -> Train path. Similar to Data Split where you had two outputs, Training Model has two inputs. One input is the data set while the other input is for the training algorithm as shown below.

Including Train model to perform Prediction in Azure Machine Learning.

As observed in the above screenshot, the training dataset is connected to the second input of the Train Model while the algorithm is connected to the first input. In this example, we have chosen the Two-Class decision jungle algorithm whereas there are a lot of available algorithms to choose from.

The following list contains the list of available algorithms for Prediction in Azure Machine Learning:

The list of available algorithms for Azure Machine Learning.

We will be discussing these techniques in future articles with details as every technique has different types of usages.

In the trained model, we need to choose the class variable since we have chosen a classification technique. For this data set, we are looking at predicting BikeBuyer, hence we will be choosing the BikeBuyer variable as shown in the below screenshot.

Chosing BukeBuyer as the classification variable.

The Score Model

After the model is trained, let us see how the model is predicted using Machine Learning -> Score -> Score Model control. The Score model has two inputs, one from the train model and the other one is test data set from split data control as shown in the below screenshot.

Including the Score model

We can view the output from the score model as shown in the below screenshot

Output of the score model in the Azure Machine Learning.

In the above screen, Bike Buyer is the actual value whereas scored labels are the predicted value with probability.

Evaluating the Model

As you know, every algorithm has its own evaluation parameters. Model evaluation can be done from the control Machine Learning -> Evaluate -> Evaluate Model. With the inclusion of the Evaluation model, an experiment for Prediction in Azure Machine Learning is completed as shown in the below screenshot.

Completed model with all controls.

Let us see the Evaluate Model output and it is important to note that, evaluation parameters are different from the technique that you used. Since we have chosen classification techniques, we will see most of the output, relevant to classification techniques such as Precision/Recall.

Precision and Recall in AML.

Following is the confusion matric and other accuracy parameters such as Accuracy, Precision, Recall and F1 score as shown in the below screenshot.

Confusion Matrix.

Publish to Gallery

You can publish the created experiment if you wish to share it with others. For this, you can use the Publish to Gallery option as shown below.

Publish to Gallery option in AML.

When the above option is clicked, the following screen will appear.

Entering Experiment description before publishing to the gallery.

In this screen, you need to enter the Experiment Name, which is the Prediction in Azure Machine Learning. Tag names are entered so that this can be easily searched. Summary and description are entered so that the consumer knows what is the model that they are selecting.

From the following screen, a proper image can be selected so that a better interface can be viewed.

Selection of Images for the Model before publishing.

There are available images and also, you have an option to choose your own image to brand your model. After the image selection, next is to decide whether the model is available to the public or whether it is available to users who have the direct link which you have shared.

Final settings in publishing the model option.

After publishing the built model, you will have the following screen.

After publishing the model.

Deployment of Azure Model

When the model is deployed, any user who does not have any understanding of the Machine Learning technique can use this model for their usages. For example, your marketing team can utilize this model to find out who are the most prospective customers from the existing list without knowing the technical details of Machine Learning.

There are a few changes needed for the previously created model. In the model, we need to eliminate unnecessary columns such as CustomerKey, etc. If not, those attributes will be shown as inputs. Let us remove these unnecessary columns and upload the file again to the Azure Machine Learning dataset. Then we do not need the filter columns and the final model will look like the following screenshot.

New model to setup web service.

Then we need to set up this model as a web service so that it is usable. Make sure you have saved the model and run the model successfully in order to set up the web service.

Option to Set up Web Service.

When the web service is created, a new tab named predictive experiment will appear as shown in the below screenshot.

Predictive Experiment in Azure Machine Learning.

When you go to the web service on the left-hand side, you will see the web service that was created for Prediction in Azure Machine Learning.

Webservice for Prediction in Azure Machine Learning.

In this, you can perform the prediction in Azure Machine Learning.

You can either do a prediction for one entry or for a batch. The following screenshot shows how to perform Prediction in Azure Machine Learning for a single entry.

Providing Inputs to prediction.

After you enter the values, click the Test Response option and you will see the result in the right-hand side as shown in the below screenshot.

Prediction output with the probabilities.

As shown in the above screenshot, it was predicted as a bike buyer with 77% of probability.

Applications

Prediction in Azure Machine Learning can be done using other tools such as Excel and other customize tools. You can find the relevant code for C#, Python, and R.

Conclusion

In this article, we discussed how prediction can be done in the Azure Machine learning by building the model and setting up as a web service. Further, we can publish the built model so that others can use the built model.

Table of contents

Introduction to Azure Machine Learning using Azure ML Studio
Data Cleansing in Azure Machine Learning
Prediction in Azure Machine Learning
Feature Selection in Azure Machine Learning
Data Reduction Technique: Principal Component Analysis in Azure Machine Learning
Prediction with Regression in Azure Machine Learning
Prediction with Classification in Azure Machine Learning
Comparing models in Azure Machine Learning
Cross Validation in Azure Machine Learning
Clustering in Azure Machine Learning
Tune Model Hyperparameters for Azure Machine Learning models
Time Series Anomaly Detection in Azure Machine Learning
Designing Recommender Systems in Azure Machine Learning
Language Detection in Azure Machine Learning with basic Text Analytics Techniques
Azure Machine Learning: Named Entity Recognition in Text Analytics
Filter based Feature Selection in Text Analytics
Latent Dirichlet Allocation in Text Analytics
Recommender Systems for Customer Reviews
AutoML in Azure Machine Learning
AutoML in Azure Machine Learning for Regression and Time Series
Building Ensemble Classifiers in Azure Machine Learning
Text Classification in Azure Machine Learning using Word Vectors
Dinesh Asanka
168 Views