ML 03 – Which version of R and R Packages running on Azure Machine Learning Service?


It is possible to run not only Python but also custom R scripts on Azure Machine Learning (AML) service. There exist several R versions and many optional R packages around. What about compatibility? Is AML possible to run the same R script that is already running on your local machine? Which R packages are installed on AML?

Following experiments will answer the above questions and we will develop our first AML experiment with a custom R script.

 

In our previous blog post, we mentioned about R and R Studio and also developed a simple R script that runs an ML model.

(quote from prev. post) You can get the free open source development environment and libraries from https://www.r-project.org. Moreover, a free IDE with GUI can be found at https://www.rstudio.com. There also exist hundreds of open source algorithms, software libraries under https://cran.r-project.org.

  1. Open R Studio and type the following simple code on the console window and press ENTER

    > version

 

    output will be something like:

    Here we run the R command named "version" which returns the R version related details and print them on the command window. version.string or minor/major values in the output window are the version of R environment installed on our machine. In our case local R version is: 3.1.0

  1. Now try to do the same in AML. Referring to our previous blog post, open Microsoft Azure ML Studio, create a blank Experiment.

     

     

  2. From the toolbar/modules bar on the left, drag and drop an "Execute R Script" module on the empty canvas. If you can't find the "Execute R Script" module within tens of other modules, just type one of the words in "Execute R Script" into the search box on the left top corner of the window on modules bar.

     

     

  3. Referring the above screenshot, click on the module (make the "Execute R Script" module selected). Then you will see properties window on the right side of the main window. Under properties window, you can write your custom R script within the "R Script" text box.

     

    Select all text inside "R Script" textbox and delete them. Now copy/paste the following custom R code inside the textbox.

           

v <- version

property <- as.character(names(v))

value <- as.character(v)

data.set <- as.data.frame(cbind(property, value))

maml.mapOutputPort("data.set");

 

 

  1. Now press on the RUN button on the bottom of the window to run this experiment. Once the experiment run successfully, you can see the green checkmark on right top corner of the canvas and each module in the experiment.

  2. So what is the output of this experiment? In AML, almost every module has input and output ports. Each module is a part of execution pipeline. To see the output of this R module, click on the port number 1 on "Execute R Script Module". Then select "Visualize" command from the popup menu items.

  3. Clicking on the Visualize command will open another window with the results that we expected. Evaluating the result window, output is same as our local result. We are running exactly the same R environment as AML.

  4. What about the installed R packages on AML? Typing command "installed.packages()" in R Studio will print out the local installed package list. To do the same in AML, just copy paste the following script as we do for "version" and view the result from port number 1

data.set <- data.frame(installed.packages())

maml.mapOutputPort("data.set")

 

TODO: In our upcoming post, we will mention about installing and running custom R packages. Developing own R learning model and using it in a native AML experiment.


Skip to main content