locked
Matching word table with dictionary, giving output wrong RRS feed

  • Question

  • Hello!

    I have this word table, and this word dictionary. I am using this R code,

    # Map 1-based optional input ports to variables

    dataset1 <- maml.mapInputPort(1) # class: data.frame
    ## Words
    dataset2 <- maml.mapInputPort(2) # class: data.frame
    ## dictionary
    data.set <- matrix(match(dataset1, dataset2), nrow = nrow(dataset1))
    data.set <- as.data.frame (data.set)
    # Select data.frame to be sent to the output Dataset port
    maml.mapOutputPort("data.set"); 

    That should return a 79 by 105 table consists of the word position in the dictionary that only match with the word table. and delete rest of the words which do not exist in the dictionary. For example:

    4489 NA   NA.................

    NA    NA    NA..............

    ....

    Same R code is working in RStudio, but in AML it is returning 79 rows and 2 columns only. Pls help.

     

    Wednesday, February 17, 2016 7:36 PM

Answers

  • Hi Bipul,

    I believe you are having issues with the data type being a data.frame in Azure ML.

    I created a quick experiment and this seems to work:

    Datasets:

    The other dataset is the same as your file. The code within the 'Execute R Script' module is as follows:

    # Map 1-based optional input ports to variables
    dataset1 <- maml.mapInputPort(1) # class: data.frame
    dataset2 <- maml.mapInputPort(2) # class: data.frame
    max_cols <- ncol(dataset1)
    match_output <- match(as.list(t(dataset1)), as.list(t(dataset2)))
    out <- data.frame(matrix(unlist(match_output), ncol = max_cols, byrow = TRUE))
    # Select data.frame to be sent to the output Dataset port
    maml.mapOutputPort("out");

    Sample output is as follows:

    Could you check if this works?

    Regards,
    Jaya


    Wednesday, February 17, 2016 11:11 PM

All replies

  • Hi Bipul,

    I believe you are having issues with the data type being a data.frame in Azure ML.

    I created a quick experiment and this seems to work:

    Datasets:

    The other dataset is the same as your file. The code within the 'Execute R Script' module is as follows:

    # Map 1-based optional input ports to variables
    dataset1 <- maml.mapInputPort(1) # class: data.frame
    dataset2 <- maml.mapInputPort(2) # class: data.frame
    max_cols <- ncol(dataset1)
    match_output <- match(as.list(t(dataset1)), as.list(t(dataset2)))
    out <- data.frame(matrix(unlist(match_output), ncol = max_cols, byrow = TRUE))
    # Select data.frame to be sent to the output Dataset port
    maml.mapOutputPort("out");

    Sample output is as follows:

    Could you check if this works?

    Regards,
    Jaya


    Wednesday, February 17, 2016 11:11 PM
  • Hello Jaya,

    It is working wonderfully. Thank you very much really. I have really understanding problem of AML data frame from normal R script. Can you suggest any documentation that I can overcome this problem.

    Warm Regards,

    Bipu

    Thursday, February 18, 2016 12:27 AM
  • Hi Bipul,

    Good to hear your issue is resolved, thanks for the confirmation.

    I am not sure how useful this documentation is, but here is what we have on R in Azure ML: https://azure.microsoft.com/en-us/documentation/articles/machine-learning-r-quickstart/

    Regards,
    Jaya

    Thursday, February 18, 2016 2:23 PM