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
Add or Subtract a value from a macro's value
Hi all,
I think this is an easy question, but I've been at it for far too long now.
OK, I've got a macro "NumberExamples" which is just a macro which gives me the number of examples for a certain attribute.
The thing I want to do is add or subtract a number from that value, so let's say the value of "NumberExamples" = 14. I want to do this 14+1 and make it 15, or 14-3 and make it 11.
However, when I try to do this with generate macro it literally adds the 1 to the number making it 141.
I know that this is probably very straightforward, I just don't know how.
Thanks
-Prentice
I think this is an easy question, but I've been at it for far too long now.
OK, I've got a macro "NumberExamples" which is just a macro which gives me the number of examples for a certain attribute.
The thing I want to do is add or subtract a number from that value, so let's say the value of "NumberExamples" = 14. I want to do this 14+1 and make it 15, or 14-3 and make it 11.
However, when I try to do this with generate macro it literally adds the 1 to the number making it 141.
I know that this is probably very straightforward, I just don't know how.
Thanks
-Prentice
0
Best Answer
-
rfuentealba RapidMiner Certified Analyst, Member, University Professor Posts: 568 UnicornHello, @Prentice,
The macro value is always a string. What you want to do is to use eval() as a method to convert it to integer.
Please check this XML as an example on how to do what you want:<?xml version="1.0" encoding="UTF-8"?><process version="9.2.000"> <context> <input/> <output/> <macros/> </context> <operator activated="true" class="process" compatibility="9.2.000" expanded="true" name="Process"> <parameter key="logverbosity" value="init"/> <parameter key="random_seed" value="2001"/> <parameter key="send_mail" value="never"/> <parameter key="notification_email" value=""/> <parameter key="process_duration_for_mail" value="30"/> <parameter key="encoding" value="SYSTEM"/> <process expanded="true"> <operator activated="true" class="concurrency:loop" compatibility="9.2.000" expanded="true" height="82" name="Loop" width="90" x="45" y="34"> <parameter key="number_of_iterations" value="5"/> <parameter key="iteration_macro" value="iterator"/> <parameter key="reuse_results" value="false"/> <parameter key="enable_parallel_execution" value="false"/> <process expanded="true"> <operator activated="true" class="generate_macro" compatibility="9.2.000" expanded="true" height="82" name="Generate Macro" width="90" x="45" y="34"> <list key="function_descriptions"> <parameter key="value" value="eval(%{iterator}) * 50"/> </list> </operator> <operator activated="true" class="print_to_console" compatibility="9.2.000" expanded="true" height="82" name="Print to Console" width="90" x="179" y="34"> <parameter key="log_value" value="%{value}"/> </operator> <connect from_port="input 1" to_op="Generate Macro" to_port="through 1"/> <connect from_op="Generate Macro" from_port="through 1" to_op="Print to Console" to_port="through 1"/> <connect from_op="Print to Console" from_port="through 1" to_port="output 1"/> <portSpacing port="source_input 1" spacing="0"/> <portSpacing port="source_input 2" spacing="0"/> <portSpacing port="sink_output 1" spacing="0"/> <portSpacing port="sink_output 2" spacing="0"/> </process> </operator> <connect from_op="Loop" from_port="output 1" to_port="result 1"/> <portSpacing port="source_input 1" spacing="0"/> <portSpacing port="sink_result 1" spacing="0"/> <portSpacing port="sink_result 2" spacing="0"/> </process> </operator> </process>
Hope this helps,
Rodrigo.
2
Answers