Due to recent updates, all users are required to create an Altair One account to login to the RapidMiner community. Click the Register button to create your account using the same email that you have previously used to login to the RapidMiner community. This will ensure that any previously created content will be synced to your Altair One account. Once you login, you will be asked to provide a username that identifies you to other Community users. Email us at Community with questions.

Use a Loop Macro in a Function Expression

mugicagonzalez_mugicagonzalez_ Member Posts: 14 Contributor I
edited January 2019 in Help
Hello all

It's possible to "Generate Attribute" with a function expression that includes an attribute (for example var1 = var + 1).
If I now want to replace these variables with macros, it doesn't work (because it is seen as text, and not as a variable). (for example %{loop-var} = %{loop-var} + 1

Example in here (all imported vars starting with Wh are numerical).
<div><?xml version="1.0" encoding="UTF-8"?><process version="8.1.003"></div><div>&nbsp; <context></div><div>&nbsp; &nbsp; <input/></div><div>&nbsp; &nbsp; <output/></div><div>&nbsp; &nbsp; <macros/></div><div>&nbsp; </context></div><div>&nbsp; <operator activated="true" class="process" compatibility="8.1.003" expanded="true" name="Process"></div><div>&nbsp; &nbsp; <process expanded="true"></div><div>&nbsp; &nbsp; &nbsp; <operator activated="true" class="retrieve" compatibility="8.1.003" expanded="true" height="68" name="Retrieve values" width="90" x="45" y="34"></div><div>&nbsp; &nbsp; &nbsp; &nbsp; <parameter key="repository_entry" value="//Local Repository/data/delete_me/values"/></div><div>&nbsp; &nbsp; &nbsp; </operator></div><div>&nbsp; &nbsp; &nbsp; <operator activated="true" class="concurrency:loop_attributes" compatibility="8.1.003" expanded="true" height="82" name="Loop Attributes" width="90" x="179" y="34"></div><div>&nbsp; &nbsp; &nbsp; &nbsp; <parameter key="attribute_filter_type" value="regular_expression"/></div><div>&nbsp; &nbsp; &nbsp; &nbsp; <parameter key="regular_expression" value="Wh_.+"/></div><div>&nbsp; &nbsp; &nbsp; &nbsp; <parameter key="attribute_name_macro" value="loop_Wh"/></div><div>&nbsp; &nbsp; &nbsp; &nbsp; <parameter key="enable_parallel_execution" value="false"/></div><div>&nbsp; &nbsp; &nbsp; &nbsp; <process expanded="true"></div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <operator activated="true" class="generate_attributes" compatibility="8.1.003" expanded="true" height="82" name="Generate Attributes (11)" width="90" x="112" y="34"></div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <list key="function_descriptions"></div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <parameter key="k%{loop_Wh}" value="%{loop_Wh} / 1000"/></div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </list></div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </operator></div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <connect from_port="input 1" to_op="Generate Attributes (11)" to_port="example set input"/></div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <connect from_op="Generate Attributes (11)" from_port="example set output" to_port="output 1"/></div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <portSpacing port="source_input 1" spacing="0"/></div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <portSpacing port="source_input 2" spacing="0"/></div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <portSpacing port="sink_output 1" spacing="0"/></div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <portSpacing port="sink_output 2" spacing="0"/></div><div>&nbsp; &nbsp; &nbsp; &nbsp; </process></div><div>&nbsp; &nbsp; &nbsp; </operator></div><div>&nbsp; &nbsp; &nbsp; <connect from_op="Retrieve values" from_port="output" to_op="Loop Attributes" to_port="input 1"/></div><div>&nbsp; &nbsp; &nbsp; <connect from_op="Loop Attributes" from_port="output 1" to_port="result 1"/></div><div>&nbsp; &nbsp; &nbsp; <portSpacing port="source_input 1" spacing="0"/></div><div>&nbsp; &nbsp; &nbsp; <portSpacing port="sink_result 1" spacing="0"/></div><div>&nbsp; &nbsp; &nbsp; <portSpacing port="sink_result 2" spacing="0"/></div><div>&nbsp; &nbsp; </process></div><div>&nbsp; </operator></div><div></process></div>


How do I bypass this?

Thanks
Pello 

Best Answer

  • mugicagonzalez_mugicagonzalez_ Member Posts: 14 Contributor I
    Solution Accepted
    Solved by using the "eval" function: eval(%{loop-var}) = eval(%{loop-var}) + 1
Sign In or Register to comment.