locked
could not output a data frame in Azure RRS feed

  • Question

  • I am new Azure ML users. I ran the following R  codes in the Execute R script with an error.

    > install.packages("src/AnomalyDetection.zip", lib = ".", repos = NULL, verbose = TRUE)
    > library(AnomalyDetection, lib.loc=".", verbose=TRUE)

    > data(raw_data)
    > res = AnomalyDetectionTs(raw_data, max_anoms=0.02, direction='both', longterm = T, plot=TRUE)
    > res$plot

    > maml.mapOutputPort("res$anoms")

    Because I want to output the variable "res$anoms" with maml.mapOutputPort("res$anoms"), Azure generated an error message, saying that "Azure Error 0063:  object 'res$anoms' not found ".

    From my understanding, Azure can only output data frame. "res" variable is a list that contain two elements, one is plot and another is anoms. "res$anoms" is a data frame. So why does  Azure  not work with this variable.

    Then I tried  the following codes

    anomalies = data.frame(res$anoms[,1], res$anoms[,2])
    maml.mapOutputPort("anomalies ");

    Now Azure works well.

    Could you tell me what is wrong with using the first method?

    Thank you in advance.


    • Edited by CRC RNAD Thursday, January 14, 2016 9:10 PM
    Thursday, January 14, 2016 8:43 PM

Answers

  • Ah that's because we do a get by name, and the name is taken to be the full string. An object named "res$anoms" doesn't exist (it is called "res" and has an "anoms" element), hence it fails.

    You should still be able to do

    temp <- res$anoms

    maml.mapOutputPort("temp")

    for the first style if you wish.

    Regards,

    AK

    Thursday, January 14, 2016 9:07 PM

All replies

  • Ah that's because we do a get by name, and the name is taken to be the full string. An object named "res$anoms" doesn't exist (it is called "res" and has an "anoms" element), hence it fails.

    You should still be able to do

    temp <- res$anoms

    maml.mapOutputPort("temp")

    for the first style if you wish.

    Regards,

    AK

    Thursday, January 14, 2016 9:07 PM
  • Hi AK,

    Thank you for your explanation. 

    After I followed the codes your provided, it still failed. the error log says "RPackage library exception: Failed to convert RObject to DataSet"

    It only works with using the res$anoms to create a new data frame and outputing this new data frame. Is something I did wrong?

    Best regards,



    • Edited by CRC RNAD Friday, January 15, 2016 1:32 PM
    Friday, January 15, 2016 1:29 PM
  • Probably Azure Ml was considering you res$anoms as a column so was trying to copy that column and as long is t a data frame it failed, 

    Once you explicitly initialized a data frame with res$anoms columns 1 and 2 it worked .

    Regards

    Friday, January 15, 2016 2:22 PM