Using R in Azure Machine Learning Studio

Example bellow will show how to import data from system:inmation using R language and inmation Web API. URL can be generated using Swagger or Postman tools.

Execute R Script

Functions can be invoked by adding Execute R Script tile. Example code for importing data from HTTP:

install.packages("rjson")
library("rjson")

install.packages("httr")
require("httr")

username = ''
password = ''

url = ''
res = GET(url, authenticate(username,password, type = 'basic'))

data_text = content(res, "text")
data_json = fromJSON(data_text)

dataframe = c()
for (item in data_json$data$items){
    for( interval in item$intervals ) {
        value = c()
        time = c()
        quality = c()
        value = c(value, interval$V)
        time = c(time, interval$T)
        quality = c(quality, interval$Q)
        dataframe = c(dataframe, value, time, quality)
    }
}

rmatrix <- matrix(unlist(dataframe), ncol=3, byrow=T)
colnames(rmatrix) <- c("Value", "Time", "Quality")

df <- data.frame(rmatrix,stringsAsFactors=FALSE)
maml.mapOutputPort("df")

Copy the script example, fill in credentials, URL and click on run.

Access input data

After successful execution green tick mark will be displayed at the top right corner of the screen.

To view the imported data, click the right mouse button, choose Result Data set, Visualize option. Various statistics about each column are displayed. Data can be modified and filtered, missing values deleted or replaced.

What can your company create using Azure ML Studio and system:inmation?

We at inmation hope that the data flow easiness between system:inmation and the Azure ML Studio enables our customers to freely work with machine learning. Create your experiments and do not forget to share your successes with us.