The Altair Community is migrating to a new platform to provide a better experience for you. In preparation for the migration, the Altair Community is on read-only mode from October 28 - November 6, 2024. Technical support via cases will continue to work as is. For any urgent requests from Students/Faculty members, please submit the form linked here

Generate a Function & apply it to all/some attributes automatically

1705410G1705410G Member Posts: 43 Learner III
edited January 2019 in Help
I've created a new attribute using the Generate Attribute operator. 
Attribute name N_speed, with 'N' representing the location. 
E.g. 2_speed represents speed at location 2. 

(New) Attribute Name:             2speed 
Function Expressions:             if([2_speed]>=70,"DANGER","SAFE").

However, I have nearly 300 attributes. I've tried adding new entries and replacing each with the name of the next attribute, but its just too much work. 

Hence, Is there any way to apply the same function to all attributes automatically? 

if([2_speed]>=70,"DANGER","SAFE")
if([3_speed]>=70,"DANGER","SAFE")
if([4_speed]>=70,"DANGER","SAFE")
if([5_speed]>=70,"DANGER","SAFE")
if([6_speed]>=70,"DANGER","SAFE")
if([7_speed]>=70,"DANGER","SAFE") and so on... 


Thanks.

Regards,
AY

Best Answers

Answers

  • 1705410G1705410G Member Posts: 43 Learner III
    edited January 2019
    @ mschmitz 

    Hi! I tried using it earlier on, but failed.
    Hence, What are the Parameters of Loop Attributes I should make changes to?

    How can I insert the function expression?

    Regards,
    AY

  • 1705410G1705410G Member Posts: 43 Learner III
    edited January 2019
    Hi lionelderkrikor ,

    Do I have to change the attribute name and function to my own attribute name or should I leave it to what you've provided me?

    As I kept getting this error inside the Generate Attribute operator.
    Expression Evaluation Error: The function 'eval' failed to parse the subexpression '2_speed'. Cause: token recognition error at '_'  

    And how do I make an exception for my date_time? So that it wouldn't be involved in any looping?

    P.S. I've also changed my function to if(([2_speed]<=35),"LOW",if(([2_speed]<=53),"MODERATE",if(([2_speed]<=70),"HIGH","VERY HIGH"))) instead. How should I insert it?

    Regards,
    AY
  • 1705410G1705410G Member Posts: 43 Learner III
    edited January 2019
    Hi lionelderkrikor ,

    Also, after pasting it in the process, I do not have the loop_attribute macro  (inside Generate Attribute) as compared to pasting it into a brand new process. Does it matter?

    Regards,
    AY

  • 1705410G1705410G Member Posts: 43 Learner III
    edited January 2019
    Hi Telcontar120 

    Sorry, I don't get what you mean. I followed the steps shown in the video below but the error stills occur.

    Expression Evaluation Error: The function 'eval' failed to parse the subexpression '2_speed'. Cause: token recognition error at '_'  .

    Does it mean that I have to remove the underscore used in all my attributes' name?

    Video Reference: https://academy.rapidminer.com/learn/video/loop-attributes

    Regards,
    AY
  • SGolbertSGolbert RapidMiner Certified Analyst, Member Posts: 344 Unicorn

    at this point providing a sample dataset and process would help a lot.

    Regards,
    Sebastian
  • 1705410G1705410G Member Posts: 43 Learner III
    SGolbert,

    Sorry, but I won't be able to share any dataset and process as it is school related. :( 

    However, what I has is 2 Loop Attributes Operator, each containing a Generate Attribute Operator.

    Attribute Name(Inside Generate Attribute) for both Loop Attributes Operator: %{loop_attribute}

    Function for 1st Loop Attributes Operator: if((eval(%{loop_attribute})<=35),"LOW",if((eval(%{loop_attribute})<=53),"MODERATE",if((eval(%{loop_attribute})<=70),"HIGH","VERY HIGH")))

    Function for 1st Loop Attributes Operator: if((eval(%{loop_attribute})<=35),"LOW",if((eval(%{loop_attribute})<=53),"MODERATE",if((eval(%{loop_attribute})<=70),"HIGH","VERY HIGH")))

    This are the errors I've been receiving (Shown in below). 
    But I've selected subset in attribute filter type. Iterations should not have been 0. 



    I am very confused. Once I solved the first error, second error pops up. Solved it, first error back again and vice versa. I've changed my naming countless times, with underscore to no underscore, numbers (10) to spelling (ten). 

    I have no idea what went wrong.

    Hope this can help you better analyse!

    Regards,
    AY

  • 1705410G1705410G Member Posts: 43 Learner III
    edited January 2019
    -
  • 1705410G1705410G Member Posts: 43 Learner III
    @ mschmitz 

    Hi! I tried using it earlier on, but failed.
    Hence, What are the Parameters of Loop Attributes I should make changes to?


    Regards,
    AY
  • 1705410G1705410G Member Posts: 43 Learner III
    Hi lionelderkrikor ,

    Do I have to change the attribute name and function inside the Generate Attribute operator to my own attribute name or should I leave it to what you've provided me? 

    As I kept getting this error inside the Generate Attribute operator.
    Expression Evaluation Error: The function 'eval' failed to parse the subexpression '2_speed'. Cause: token recognition error at '_'  

    Regards,
    AY
  • 1705410G1705410G Member Posts: 43 Learner III
    Hi lionelderkrikor ,

    Just to add on, how do I copy your codes into my process without removing my other existing operators? As I can only paste into a new process.

    Regards,
    AY
  • 1705410G1705410G Member Posts: 43 Learner III
    SGolbert,

    Sorry, but I won't be able to share any dataset and process as it is school related. :( 

    However, what I has is 2 Loop Attributes Operator, each containing a Generate Attribute Operator.

    Attribute Name(Inside Generate Attribute) for both Loop Attributes Operator: %{loop_attribute}

    Function for 1st Loop Attributes Operator: if((eval(%{loop_attribute})<=35),"LOW",if((eval(%{loop_attribute})<=53),"MODERATE",if((eval(%{loop_attribute})<=70),"HIGH","VERY HIGH")))

    Function for 1st Loop Attributes Operator: if((eval(%{loop_attribute})<=35),"LOW",if((eval(%{loop_attribute})<=53),"MODERATE",if((eval(%{loop_attribute})<=70),"HIGH","VERY HIGH")))

    This are the errors I've been receiving (Shown in below). 
    But I've selected subset in attribute filter type. Iterations should not have been 0. 



    I am very confused. Once I solved the first error, second error pops up. Solved it, first error back again and vice versa. I've changed my naming countless times, with underscore to no underscore, numbers (10) to spelling (ten). 

    I have no idea what went wrong.

    Regards,
    AY
  • 1705410G1705410G Member Posts: 43 Learner III
    @ mschmitz 

    Hi! I tried using it earlier on, but failed.
    Hence, What are the Parameters of Loop Attributes I should make changes to?


    Regards,
    AY
  • 1705410G1705410G Member Posts: 43 Learner III
    Hi lionelderkrikor ,

    Do I have to change the attribute name and function inside the Generate Attribute operator to my own attribute name or should I leave it to what you've provided me? 

    As I kept getting this error inside the Generate Attribute operator.
    Expression Evaluation Error: The function 'eval' failed to parse the subexpression '2_speed'. Cause: token recognition error at '_'  

    Regards,
    AY
  • 1705410G1705410G Member Posts: 43 Learner III
    Hi lionelderkrikor ,

    Just to add on, how do I copy your codes into my process without removing my other existing operators? As I can only paste into a new process.

    Regards,
    AY
  • 1705410G1705410G Member Posts: 43 Learner III
    edited January 2019
    -
Sign In or Register to comment.