🎉Community Raffle - Win $25

An exclusive raffle opportunity for active members like you! Complete your profile, answer questions and get your first accepted badge to enter the raffle.
Join and Win

"Loop Attributes - Expression Evaluation Error"

User: "1705410G"
New Altair Community Member
Updated by Jocelyn
I'm using 2 separate Loop Attributes Operator, each containing a Generate Attribute Operator.

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


However, this error popped out. 
Expression Evaluation Error: The function 'eval' failed to parse the subexpression '203_10'. Cause: token recognition error at '_'  .
Initially, I thought that by removing the underscore '_' will solve it. But no matter what I did to rename it using the Rename by Replacing operator, it doesn't work. Same error comes up.



Sometimes, the Not Enough Iterations Error  pops up as well. I'm confused when I have set the Loop Attribute to subset and have selected the necessary attributes. 

Regards,
AY

Find more posts tagged with

Sort by:
1 - 7 of 71
    User: "David_A"
    New Altair Community Member
    Accepted Answer
    Hi,

    the problem here is how macros are parsed.
    In your case, first %{loop_attribute} is replaced with the attribute name, this is "2_speed". Then the eval() function tries to make sense of that string as a number or mathematical expression, what fails.

    In that case you need to use the seldom used #{loot_attribute} syntax. This returns the value corresponding to that attribute name.

    @mschmitz has described it nicely in this posting:
    https://community.rapidminer.com/discussion/50538/how-to-use-macros

    And congratulations, you are now in the higher echelons of macro handling  ;)

    Best,
    David

    User: "1705410G"
    New Altair Community Member
    OP
    Updated by 1705410G
    HI David_A 

    #{loop_attribute} syntax worked!! Thank you!! But the results seems wrong

    As mentioned above, i'm using 2 separate Loop Attributes operator.

    Attribute filter type is set to subset with about 40 different attributes selected in each Loop Attributes operator. 
     

    However, there's only 1 column of results produced by the first loop and s
    econd loop (Shown below). Does it means that both Loop Attributes only loop once?  
      


    My question is how can I allow the 2 different loops to loop for all selected attributes?
    So I should be able to get 80 new columns in total. 40 for the first loop function and 40 for the second loop function.  

    P.S. How do I get the loop attributes to use back the same name rather than #{loop_attribute} since I have 40 over attributes in each Loop Attribute operator?


    Thank you!! 

    Regards,
    AY
    User: "lionelderkrikor"
    New Altair Community Member
    Accepted Answer
    Hi @1705410G,

    Can you try to define attribute name as %{loop_attribute} (or something like %{loop_attribute}_bis if you don't want that your initial attributes are removed) instead of #{loop_attribute} :  



    Hope it helps,

    Regards,

    Lionel
    User: "1705410G"
    New Altair Community Member
    OP
    Hi 

    It worked! Thank you so much to all that contributed!


    User: "kypexin"
    New Altair Community Member
    In that case you need to use the seldom used #{loot_attribute} syntax. This returns the value corresponding to that attribute name.

    @David_A -- thanks for that secret knowledge, it took me an hour of my life to struggle with Loop Attributes before I have found this solution on the forum!

    PS one more proof how really useful and helpful RM community can be! MAGIC!

    i am quite close to write a getValueOf(String attribute) function and add it to the expression parser. I got the feeling that this would fix this hazzle.

    BR,
    Martin
    User: "kypexin"
    New Altair Community Member
    @mschmitz -- would be great!

    '#{macro}' notation is basically okay (if you know about it of course :) ), but having getValueOf(String attribute) would simplify the process structure in some cases.