RapidMiner

RapidMiner

[SOLVED]How to iterate over Attributes

Regular Contributor

[SOLVED]How to iterate over Attributes

Hello RM-Team,

I tried to iterate over the attributes with the "loop attributes"-operator, but the "select attributes"-operator seems not to work well within a loop Smiley Sad

It only work's on the first cycle, thats why I think its not my fault. Could you tell me if this is a bug, and maybe when you will fix it?


<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<process version="5.3.008">
 <context>
   <input/>
   <output/>
   <macros/>
 </context>
 <operator activated="true" class="process" compatibility="5.3.008" expanded="true" name="Process">
   <process expanded="true">
     <operator activated="true" class="generate_data" compatibility="5.3.008" expanded="true" height="60" name="Generate Data" width="90" x="179" y="30">
       <parameter key="number_examples" value="10"/>
     </operator>
     <operator activated="true" class="loop_attributes" compatibility="5.3.008" expanded="true" height="76" name="Loop Attributes" width="90" x="313" y="30">
       <process expanded="true">
         <operator activated="true" breakpoints="after" class="select_attributes" compatibility="5.3.008" expanded="true" height="76" name="Select Attributes" width="90" x="112" y="30">
           <parameter key="attribute_filter_type" value="single"/>
           <parameter key="attribute" value="%{loop_attribute}"/>
         </operator>
         <connect from_port="example set" to_op="Select Attributes" to_port="example set input"/>
         <connect from_op="Select Attributes" from_port="example set output" to_port="example set"/>
         <portSpacing port="source_example set" spacing="0"/>
         <portSpacing port="sink_example set" spacing="0"/>
         <portSpacing port="sink_result 1" spacing="0"/>
       </process>
     </operator>
     <connect from_op="Generate Data" from_port="output" to_op="Loop Attributes" to_port="example set"/>
     <connect from_op="Loop Attributes" from_port="example set" 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>


Put a breakpoint on the SAtt-operator and see the difference between the output at the first cycle and the other one's.

Best xDSticker
3 REPLIES
mdc
Regular Contributor

Re: How to iterate over Attributes


Connect the output of the Select Attribute operator to the RES output.

Matthew
Regular Contributor

Re: How to iterate over Attributes

Some of the loop operators (the ones with ports named "exa") behave differently from the rest. While other loop operators pass the same initial exampleset into each iteration, these loop operators pass the output "exa" from one iteration to the input "exa" of the next, in effect forming an iterated chain of the internal operators. The advantage of this (in most applications) is that you end up getting one exampleset at the loop operator's output, rather than a collection.

Because of this "chaining" your process amounts to selecting att1 from {att1,att2,att3,att4,att5} and then selecting att2 from {att1}, which is why it doesn't work.

You could usually just use the macro to work directly on the full exampleset without first selecting. But if you really want to select each attribute into a different exampleset you could do it like this
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<process version="5.3.008">
 <context>
   <input/>
   <output/>
   <macros/>
 </context>
 <operator activated="true" class="process" compatibility="5.3.008" expanded="true" name="Process">
   <process expanded="true">
     <operator activated="true" class="generate_data" compatibility="5.3.008" expanded="true" height="60" name="Generate Data" width="90" x="179" y="30">
       <parameter key="number_examples" value="10"/>
     </operator>
     <operator activated="true" class="loop_attributes" compatibility="5.3.008" expanded="true" height="94" name="Loop Attributes" width="90" x="313" y="30">
       <process expanded="true">
         <operator activated="true" class="select_attributes" compatibility="5.3.008" expanded="true" height="76" name="Select Attributes" width="90" x="112" y="30">
           <parameter key="attribute_filter_type" value="single"/>
           <parameter key="attribute" value="%{loop_attribute}"/>
         </operator>
         <connect from_port="example set" to_op="Select Attributes" to_port="example set input"/>
         <connect from_op="Select Attributes" from_port="example set output" to_port="result 1"/>
         <connect from_op="Select Attributes" from_port="original" to_port="example set"/>
         <portSpacing port="source_example set" spacing="0"/>
         <portSpacing port="sink_example set" spacing="0"/>
         <portSpacing port="sink_result 1" spacing="0"/>
         <portSpacing port="sink_result 2" spacing="0"/>
       </process>
     </operator>
     <connect from_op="Generate Data" from_port="output" to_op="Loop Attributes" to_port="example set"/>
     <connect from_op="Loop Attributes" from_port="result 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>
Regular Contributor

Re: [SOLVED]How to iterate over Attributes

Thank you for your help, was not easy to see this Smiley Happy