Differentiating data per attribute

bernardo_pagnonbernardo_pagnon Member, University Professor Posts: 60 University Professor
Hello all,

I have the following data 
  att1 att2   att3
1 8     9       9
2 9     10      8

So, attribute 1 can assume values 8 or 9, attribute 2 values 9 and 10, and attribute 3 values  8 and 9. Thing is, all those nines do not represent the same thing. How can I change those values in order to avoid conflict?
If I change all the nines at the same time it does not help me. In a way, I have "9 of attribute 1", "9 of attribute 2" and "9 of attribute 3". Same thing with 8 for attributes 1 and 3. How can map them (I tried the map operator and could not do it) into different numbers/representations to avoid confusion?

Regards,
Bernardo
Tagged:

Best Answer

  • varunm1varunm1 Moderator, Member Posts: 1,207 Unicorn
    Solution Accepted
    Hello @bernardo_pagnon

    You can use the "loop attribute" operator and inside that keep the "map" operator. In the below example, I used "Titanic Training" Dataset.l In this, my focus is to change value "0" present in two attributes "Number of siblings or spouses on board" and "Number of parents or children on board". I tried to replace value "0" in  "Number of siblings or spouses on board" with "1" and "Number of parents or children on board" with 2

    For this, I selected these two attributes in the loop attributes operator by selecting a subset in "attribute filter type" and then selecting the required two attributes in the attributes option. I also need to remember the macro name "loop_attribute" to be used in "map" operator. You also need to check the reuse results, that will run the loop once on first attribute and use the results of that to modify the second attribute.



    Now inside the "loop_attributes", I will set a map operator. As I need to replace the value of "0" in each attribute one by one, I will extract that attribute name based on "attribute filter type" single and then adding macro name %{loop_attribue} in attribute parameter of map operator. Then, I will replace the value "0" with 1 and 2 for different attributes. This is by using %{execution_count} macro that uses the execution count of loop attribute operator as a value (1 for the first iteration and 2 for second iteration). 



    Hope this helps. Do let us know if you need more information
    Regards,
    Varun
    https://www.varunmandalapu.com/

    Be Safe. Follow precautions and Maintain Social Distancing

Answers

  • [Deleted User][Deleted User] Posts: 0 Learner III
    @bernardo_pagnon

    Hello

    I don't have that much information about your data but may be you can change it like this:
          att1   att2     att3
    1)    8a     9b       9c
    2)    9a     10b      8c

    Regards
    mbs
  • bernardo_pagnonbernardo_pagnon Member, University Professor Posts: 60 University Professor
    Dear varunm1,

    thank you for your reply, this is exactly what I needed. I wasn't aware of the existence of the loop attributes operator!

    Best,
    Bernardo
  • bernardo_pagnonbernardo_pagnon Member, University Professor Posts: 60 University Professor
    Dear mbs,

    you are right, this is exactly what I needed, but I wanted to know how to automate it inside RM. 
    My data set is larger, I isolated the question to make it 100% clear. 
    varunm1's reply explained how to do it inside RM without having to change it manually, or using Excel. 

    Thanks for posting a comment. 

    Best,
    Bernardo

  • [Deleted User][Deleted User] Posts: 0 Learner III
    edited March 2020
    Dear @bernardo_pagnon

    Sorry for delay. I think it is not possible with RM or may be other knows more than me but if your data is in excel it is really easy to change it like this:
          att1   att2     att3
    1)    8a     9b       9c
    2)    9a     10b      8c

    you need only to select the column like this:


    then right click on the column and choose Format Cells, like this:




    then choose one number under General and add a,b,c,....
    so the result is like this: ( one alphabet add to the column)



    my data was in binary and I add "a" to one column of that. :) ( less than 1 min you can do it for each column) :)

    I hope this helps
    mbs

  • bernardo_pagnonbernardo_pagnon Member, University Professor Posts: 60 University Professor
    Interesting, that is not a bad solution outside RM. 
    Thanks mbs for the follow up!

    Best,
    Bernardo
Sign In or Register to comment.