Azure Machine Learning "Hello World" using R

Author by Concurrency Blog

I am excited to talk about my first machine learning test experiment on Azure ML Studio. This is an awesome platform for automating and speeding up the process of machine learning experiments. Azure allows us to even create a web service out of our tests and this web service can be used by even non-data scientist professionals to carry out machine learnign experiments. We are all witnessing this shift in the industry to empower the business analysts to take quick decisions and decrease the dependency on data scientists. I am going to show you a very simple experiement where I will create a very basic "Hello World" program using R script. Yes! This is another advantage of Azure ML studio that you can incorporate your R scripts and create a knowledge management system for your company. Let's get started!

Login to the Azure ML studio by going to the following link https://studio.azureml.net and click on the "NEW" icon at the bottom left corner as shown below. This will fire up a new experiment window. Select "experiment" to start your new experiment. You will then see a screen something like the shown below with blank canvas. At the top left corner to can rename the title of your experiment.mlstudio1

mlstudio2

The next step is to import the dataset you want to analyze. In my case, I have create a very simple dataset with five names of employees working at Concurrency and saved it as "Names.csv". Note that it is very important to save it in a csv format. My csv file looks something like shown below. It has only one column.

mlstudio3

When you click on dataset icon, you can import the Names.csv file by choosing the destination local file. The window looks like shown below

 mlstudio4

Once you have saved the dataset, click on the experiments icon just below the home icon. I know I am going very slowly but you can easily loose your interest in machine learning if any step gets wrong. I have had experiences where I had to spend lots of time just on correcting my mistakes and it takes time to be familiar with a new technology.

mlstudio5

Then click on the search bar beside the home icon and type in the name of your saved csv file. In my case it is Names.csv and if you see the image below.Now drag the names.csv file into the blank canvas and your screen will look something as shown below

mlstudio6

Then go back to the search bar and type in "execute R" and then as usual drag Execute R Script icon to the canvas. The screen should look something like show below

mlstudio7

Then connect the names.csv to the execute R script textbox by dragging your mouse from the output port of Names.csv to the outer left input port of execute R script textbox. You should see a screen something like shown belowmlstudio8

Once the connection is set, then click on the execute R textbox and it will be highlighted in blue colour. Once it is highlighted, you can now see a R script to the top right corner. UI of ML Studio is very user friendly and you can drag the side bar to view the default R script. You can see here that dataset1 and dataset2 represent the two input ports on the R textbox. In our case, we have only one dataset i.e. names.csv. Therefore, we do not need the second port and we must modify the code.mlstudio9

Delete the default R script and paste the script provided below. Once you replace the default script with this script, your R script should look something like shown below

mlstudio10

dataset1 <- maml.mapInputPort(1)#class: data.frame

data.set <- data.frame(response=paste0("Hello ",dataset1$Names,"!"))

maml.mapOutputPort("data.set");

you can see in teh code that we are creating "Hello " and passing the names parameter from the dataset1 which is Names.csv. Then, we are getting the results in the output port which will give the result as "Hello Jim" if the csv file contains Jim in the names column.

Click on the "RUN" icon at the bottom center of the screen as shown below

mlstudio11

Once you execute the R script by clicking on run icon, you will see that the input and output ports of the EXECUTE R SCRIPT textbox are having a grid kind of icon. This means that the result of the test run is now ready for visualization. We can have all kinds of visualization but for simplicity we will first take a look at the basic visualization with a list of items.

 mlstudio12

Now right click on the Execute R script texbox left output port that has a grid. You will now have a bunch of options. Click on VISUALIZE to take a look at the output of your R script as shown below

 mlstudio13

The output looks like below

 mlstudio14

Here you can see that the output suggests that there are 6 rows and 1 column in the dataset. There are 6 unique values which are the names of the employees at Concurrency. Finally, at the bottom, you can see the resultant output with "Hello Amit", "Hello Ted", "Hello Nate" etc.

Thats it! We have successfully worked on ML Studio to write our very first experiment. In the next blog I will explain how to deploy this experiment as a web service. This is an amazing feature as it allows to retain the knowledge of the machine learning data scientist in Azure. This will be a KMS i.e. Knowledge Management System for your company. Please comment and ask any queries that you have and subcribe to our blog by following ConcurrencyInc on twitter and LinkedIn.

Author

Concurrency Blog

The latest about Concurrency