locked
R Script as a trained model RRS feed

  • Question

  • I created an experiment that uses a regression that I created in R

    I want to set the R script as the trained model but that menu cannot be selected.  What else do I have to do to set a R Script to be a trained model?

    Thanks

    Wednesday, October 8, 2014 7:19 PM

Answers

  • Apologies, I forgot a closing parenthesis on line 61

    • Marked as answer by Jamie.DixonMVP Wednesday, October 8, 2014 10:29 PM
    Wednesday, October 8, 2014 9:06 PM

All replies

  • Native R-backed learners are not available in our production environment yet I'm afraid.

    For the time being, you will have to use the workaround that is abstractly described as:

    1) Split your R workflow into 2 Execute R Script modules

    a) First block trains, and outputs a serialized trained model (in this case the serialized representation of the returned model from the lm() call)

    b) Second block scores - you deserialize the input coming from the first module, then apply it to new data, usually using the predict() function.

    2) You then operationalize (publish) with the Input/Output around the second block.

    Related thread: http://social.msdn.microsoft.com/Forums/azure/en-US/7f2d9ea2-3845-4c0e-9108-4e6b4969f3f1/how-to-apply-2step-trainscore-experiments-in-r?forum=MachineLearning

    Wednesday, October 8, 2014 7:46 PM
  • AK

    Can you give me an example of outputting a serialized trained model using this LOC?

    lm(Private ~ Apps + Accept, data=dataset1)

    is it 

    outframe <- as.data.frame(lm(Private ~ Apps + Accept, data=dataset1))

    ???


    Wednesday, October 8, 2014 8:25 PM
  • Almost, you need the actual serialization step (and cast to integer to sidestep a bug).

    someModelName <- lm(Private ~ Apps + Accept, data=dataset1)
    outframe <- as.data.frame(as.integer(serialize(someModelName, connection=NULL)))

    BTW this requires you to complete the workflow in another Execute R Script module - it does not create a native Azure ML Trained Model, just to be explicit.

    Regards,

    AK



    Wednesday, October 8, 2014 8:42 PM
  • based on your template, I created this

    dataset1 <- maml.mapInputPort(1)
    currentModel <- lm(Private ~ Apps + Accept, data=dataset1)
    outframe <- as.data.frame(as.integer(serialize(currentModel, connection=NULL))
    maml.mapOutputPort("outframe")

    and I am getting this:

    ModuleOutput] Microsoft Drawbridge Console Host [Version 1.0.2108.0]
    [ModuleOutput] Error in source("tmp2C7A.R", print.eval = TRUE) : 
    [ModuleOutput] 
    [ModuleOutput]   tmp2C7A.R:62:1: unexpected symbol
    [ModuleOutput] 
    [ModuleOutput] 61: outframe <- as.data.frame(as.integer(serialize(currentModel, connection=NULL))
    [ModuleOutput] 
    [ModuleOutput] 62: maml.mapOutputPort
    [ModuleOutput] 

    Wednesday, October 8, 2014 8:58 PM
  • Apologies, I forgot a closing parenthesis on line 61

    • Marked as answer by Jamie.DixonMVP Wednesday, October 8, 2014 10:29 PM
    Wednesday, October 8, 2014 9:06 PM
  • So I created this:

    I still can't mark either R Script as the model.  Do I have to configure anything else?

    Wednesday, October 8, 2014 10:39 PM
  • Hey Jamie,

    That is what I meant by "BTW this requires you to complete the workflow in another Execute R Script module - it does not create a native Azure ML Trained Model, just to be explicit."

    You cannot currently create ILearner types from the Execute R Script module - the workaround is to replace the Train Model and Score Model modules with two Execute R Script modules that do training and scoring in R.

    You can then publish the second ERS module as a web service, similar to how Score Model is published.

    Does that make sense?

    Regards,

    AK

    Wednesday, October 8, 2014 10:42 PM
  • Ugh!!!!  Just emailed you.
    Wednesday, October 8, 2014 10:48 PM