How to implement

Ideal

How to implement

Quick & dirty

How to implement - AzureML demo

Setup

library("AzureML")
MLID<-"16ed88890b0644239ea800a90063bc0f"
AuthToken<-"e1e2d4f99b0041269c6435c0c6ccb07d"

How to implement - AzureML demo

Make a model

myLM<-lm(data = iris,
         Sepal.Length~Sepal.Width,
         model = FALSE)

adhocPred<-predict(myLM,
                   newdata = data.frame(
                     Sepal.Width=5.7)
                   )
adhocPred

How to implement - AzureML demo

Make a predict function

myPrediction<-function(SW=0){
  # You would store coeficients
  # In place of modelling every time!
  myCoefsLM<-coef(lm(data = iris,
           Sepal.Length~Sepal.Width,
           model = FALSE))
  myCoefScores<-crossprod(myCoefsLM,c(1,SW))
  return(sum(myCoefScores))

}

How to implement - AzureML demo

Publish a predict function

response <- publishWebService(
  "myPrediction", 
  "myPredictionOnline", 
  list("SW"="float"), 
  list("r"="float"), 
  MLID, AuthToken)

How to implement - AzureML demo

Use a published functions

webservices <- getWebServices(MLID, AuthToken)

endpoints <- getEndpoints(MLID, 
                          AuthToken, 
                          webservices[[1]]$Id)

response <- consumeLists(
  endpoints[[1]]$PrimaryKey, 
  endpoints[[1]]$ApiLocation, 
  list("SW"=9))

response


stephlocke/Rtraining documentation built on May 30, 2019, 3:36 p.m.