I would like to invert scores for a set of attributes in my table. I have selected the attributes and sent them to a "Loop Attributes" function. Within the function I have specified "Generate Attributes". For each attribute I want to place it in the denominator like so: 1/[Attribute]. It seems I have to specify an attribute name in the formula. Is there a wildcard option that I am missing? Any other solution?
1 Answers
the wildcard you are looking for is the parameter attribute name macro. This macro (what is similar to a process variable) you can build the desired function expression inside the Generate Attributes Operator, as I have done in the attached process below (simply copy&paste the xml file into the process inside RapidMiner). Be aware of the new option sind RapidMiner 7.4 when using Loop Attribtes, where can either reuse the current ExampleSet or return a collection with a single Example Set for each iteration.
For more details about macros, take a look here:
http://community.rapidminer.com/t5/RapidMiner-Studio-Knowledge-Base/How-to-Use-Macros/ta-p/32966
Especially the difference between %{macro} and eval(%{macro}) can be important.
Sample Process:
<?xml version="1.0" encoding="UTF-8"?><process version="7.4.000">
<context>
<input/>
<output/>
<macros/>
</context>
<operator activated="true" class="process" compatibility="7.4.000" expanded="true" name="Process">
<process expanded="true">
<operator activated="true" class="generate_data" compatibility="7.4.000" expanded="true" height="68" name="Generate Data" width="90" x="112" y="85"/>
<operator activated="true" class="concurrency:loop_attributes" compatibility="7.4.000" expanded="true" height="82" name="Loop Attributes" width="90" x="313" y="85">
<parameter key="reuse_results" value="true"/>
<parameter key="enable_parallel_execution" value="false"/>
<process expanded="true">
<operator activated="true" class="generate_attributes" compatibility="7.4.000" expanded="true" height="82" name="Generate Attributes" width="90" x="380" y="34">
<list key="function_descriptions">
<parameter key="%{loop_attribute}_new" value="1/eval(%{loop_attribute})"/>
</list>
</operator>
<connect from_port="input 1" to_op="Generate Attributes" to_port="example set input"/>
<connect from_op="Generate Attributes" from_port="example set output" 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="Generate Data" from_port="output" to_op="Loop Attributes" to_port="input 1"/>
<connect from_op="Loop Attributes" 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>

- 792
- 5
- 17