Using a Loop Operator to iterate through an Excel file columns

sia
sia New Altair Community Member
edited November 5 in Community Q&A
Hi All,

I am very new to RapidMiner. I am trying to setup a loop by which I can iterate through columns of label attributes in a single Excel file. I am trying to process the binomial values in each column. I would like the output to go to a single spreadsheet that contains the processed columns. Which loop operator would be the best to use? How would I iterate through different columns and aggregate the outputs?

Thanks for your help.

Answers

  • wessel
    wessel New Altair Community Member
    Hello,

    I recommend you spend some time learning about the operators that "read" and "write" data.
    Here is a process that may help you.

    Grey operators are inactive. Like read excel, and write excel. These operators will probably be useful to use.
    Right now I generate random data so the process runs out of the box.

    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    <process version="5.3.013">
      <context>
        <input/>
        <output/>
        <macros/>
      </context>
      <operator activated="true" class="process" compatibility="5.3.013" expanded="true" name="Process">
        <process expanded="true">
          <operator activated="false" class="read_excel" compatibility="5.3.013" expanded="true" height="60" name="Read Excel" width="90" x="146" y="106">
            <list key="annotations"/>
            <list key="data_set_meta_data_information"/>
          </operator>
          <operator activated="false" class="write_excel" compatibility="5.3.013" expanded="true" height="76" name="Write Excel" width="90" x="271" y="98"/>
          <operator activated="true" class="generate_data" compatibility="5.3.013" expanded="true" height="60" name="Generate Data" width="90" x="60" y="208"/>
          <operator activated="true" class="generate_id" compatibility="5.3.013" expanded="true" height="76" name="Generate ID" width="90" x="183" y="206"/>
          <operator activated="true" class="numerical_to_binominal" compatibility="5.3.013" expanded="true" height="76" name="Numerical to Binominal" width="90" x="361" y="204">
            <parameter key="max" value="11.0"/>
          </operator>
          <operator activated="false" class="generate_aggregation" compatibility="5.3.013" expanded="true" height="76" name="Generate Aggregation" width="90" x="422" y="408">
            <parameter key="attribute_name" value="att1"/>
            <parameter key="attribute_filter_type" value="single"/>
            <parameter key="attribute" value="att1"/>
          </operator>
          <operator activated="true" class="loop_attributes" compatibility="5.3.013" expanded="true" height="94" name="Loop Attributes" width="90" x="549" y="75">
            <parameter key="iteration_macro" value="ID"/>
            <process expanded="true">
              <operator activated="true" class="select_attributes" compatibility="5.3.013" expanded="true" height="76" name="Select Attributes" width="90" x="116" y="165">
                <parameter key="attribute_filter_type" value="single"/>
                <parameter key="attribute" value="%{ID}"/>
              </operator>
              <operator activated="true" class="aggregate" compatibility="5.3.013" expanded="true" height="76" name="Aggregate" width="90" x="428" y="29">
                <list key="aggregation_attributes">
                  <parameter key="%{ID}" value="mode"/>
                </list>
              </operator>
              <operator activated="true" class="filter_examples" compatibility="5.3.013" expanded="true" height="76" name="Filter Examples" width="90" x="457" y="207"/>
              <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_op="Aggregate" to_port="example set input"/>
              <connect from_op="Select Attributes" from_port="original" to_op="Filter Examples" to_port="example set input"/>
              <connect from_op="Aggregate" from_port="example set output" to_port="result 1"/>
              <connect from_op="Filter Examples" 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>
          <operator activated="true" class="loop_collection" compatibility="5.3.013" expanded="true" height="76" name="TODO" width="90" x="698" y="208">
            <process expanded="true">
              <connect from_port="single" to_port="output 1"/>
              <portSpacing port="source_single" 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="Generate ID" to_port="example set input"/>
          <connect from_op="Generate ID" from_port="example set output" to_op="Numerical to Binominal" to_port="example set input"/>
          <connect from_op="Numerical to Binominal" from_port="example set output" to_op="Loop Attributes" to_port="example set"/>
          <connect from_op="Loop Attributes" from_port="result 1" to_op="TODO" to_port="collection"/>
          <connect from_op="TODO" 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>