"Loop until the exampleset is empty."

mdcmdc Member Posts: 58 Maven
edited May 2019 in Help
Hi,

I'm trying to find the operator/s that I could use to execute a subprocess repeatedly until a certain exampleset is empty. I have a feeling that it should be the 'Loop Until'. However, it requires a performance input which I don't have. I also searched the forum but couldn't find any answer.

Any idea?

thanks.

Answers

  • mdcmdc Member Posts: 58 Maven

    Here's a test process to illustrate my objective. It uses the Loop Until operator. However, it doesn't work. There's the error that there's no data delivered to the port Loop Until.performance.

    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    <process version="5.1.001">
      <context>
        <input/>
        <output/>
        <macros/>
      </context>
      <operator activated="true" class="process" compatibility="5.1.001" expanded="true" name="Root">
        <process expanded="true" height="379" width="705">
          <operator activated="true" class="retrieve" compatibility="5.1.001" expanded="true" height="60" name="Retrieve" width="90" x="45" y="30">
            <parameter key="repository_entry" value="//Samples/data/Iris"/>
          </operator>
          <operator activated="true" class="multiply" compatibility="5.1.001" expanded="true" height="112" name="Multiply" width="90" x="180" y="30"/>
          <operator activated="true" class="set_minus" compatibility="5.1.001" expanded="true" height="76" name="Create EmptySet" width="90" x="315" y="30"/>
          <operator activated="true" class="remember" compatibility="5.1.001" expanded="true" height="60" name="Remember" width="90" x="450" y="30">
            <parameter key="name" value="TEMP"/>
            <parameter key="io_object" value="ExampleSet"/>
          </operator>
          <operator activated="true" class="loop_until" compatibility="5.1.001" expanded="true" height="76" name="Loop Until" width="90" x="313" y="165">
            <process expanded="true" height="386" width="681">
              <operator activated="true" class="recall" compatibility="5.1.001" expanded="true" height="60" name="Recall" width="90" x="45" y="210">
                <parameter key="name" value="TEMP"/>
                <parameter key="io_object" value="ExampleSet"/>
              </operator>
              <operator activated="true" class="set_minus" compatibility="5.1.001" expanded="true" height="76" name="Set Minus" width="90" x="112" y="75"/>
              <operator activated="true" class="sample" compatibility="5.1.001" expanded="true" height="76" name="Sample" width="90" x="246" y="75">
                <parameter key="sample_size" value="1"/>
                <list key="sample_size_per_class"/>
                <list key="sample_ratio_per_class"/>
                <list key="sample_probability_per_class"/>
              </operator>
              <operator activated="true" class="remember" compatibility="5.1.001" expanded="true" height="60" name="Remember (2)" width="90" x="380" y="75">
                <parameter key="name" value="TEMP"/>
                <parameter key="io_object" value="ExampleSet"/>
              </operator>
              <operator activated="true" class="extract_performance" compatibility="5.1.001" expanded="true" height="76" name="Performance" width="90" x="514" y="75">
                <parameter key="performance_type" value="number_of_attributes"/>
              </operator>
              <connect from_port="input 1" to_op="Set Minus" to_port="example set input"/>
              <connect from_op="Recall" from_port="result" to_op="Set Minus" to_port="subtrahend"/>
              <connect from_op="Set Minus" from_port="example set output" to_op="Sample" to_port="example set input"/>
              <connect from_op="Sample" from_port="example set output" to_op="Remember (2)" to_port="store"/>
              <connect from_op="Remember (2)" from_port="stored" to_op="Performance" to_port="example set"/>
              <connect from_op="Performance" from_port="performance" to_port="performance"/>
              <connect from_op="Performance" from_port="example set" to_port="example set"/>
              <portSpacing port="source_input 1" spacing="0"/>
              <portSpacing port="source_input 2" spacing="0"/>
              <portSpacing port="sink_performance" spacing="36"/>
              <portSpacing port="sink_example set" spacing="18"/>
              <portSpacing port="sink_output 1" spacing="0"/>
              <portSpacing port="sink_output 2" spacing="0"/>
            </process>
          </operator>
          <connect from_op="Retrieve" from_port="output" to_op="Multiply" to_port="input"/>
          <connect from_op="Multiply" from_port="output 1" to_op="Create EmptySet" to_port="example set input"/>
          <connect from_op="Multiply" from_port="output 2" to_op="Create EmptySet" to_port="subtrahend"/>
          <connect from_op="Multiply" from_port="output 3" to_op="Loop Until" to_port="input 1"/>
          <connect from_op="Create EmptySet" from_port="example set output" to_op="Remember" to_port="store"/>
          <connect from_op="Loop Until" 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>
    Is the Loop Until operator the right choice for this?

    thanks.
  • haddockhaddock Member Posts: 849 Maven
    I think you can do it with "Loop" and macros, like this....
    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    <process version="5.1.001">
      <context>
        <input/>
        <output/>
        <macros/>
      </context>
      <operator activated="true" class="process" compatibility="5.1.001" expanded="true" name="Root">
        <process expanded="true" height="379" width="705">
          <operator activated="true" class="retrieve" compatibility="5.1.001" expanded="true" height="60" name="Retrieve" width="90" x="45" y="30">
            <parameter key="repository_entry" value="//Samples/data/Iris"/>
          </operator>
          <operator activated="true" class="extract_macro" compatibility="5.1.001" expanded="true" height="60" name="Extract Macro" width="90" x="186" y="19">
            <parameter key="macro" value="Count"/>
          </operator>
          <operator activated="true" class="loop" compatibility="5.1.001" expanded="true" height="76" name="Loop" width="90" x="313" y="30">
            <parameter key="iterations" value="%{Count}"/>
            <process expanded="true" height="357" width="872">
              <operator activated="true" class="filter_example_range" compatibility="5.1.001" expanded="true" height="76" name="Filter Example Range" width="90" x="112" y="30">
                <parameter key="first_example" value="%{a}"/>
                <parameter key="last_example" value="%{Count}"/>
              </operator>
              <operator activated="true" class="extract_macro" compatibility="5.1.001" expanded="true" height="60" name="Extract Macro (2)" width="90" x="246" y="30">
                <parameter key="macro" value="Sub_Count"/>
              </operator>
              <operator activated="true" class="provide_macro_as_log_value" compatibility="5.1.001" expanded="true" height="76" name="Provide Macro as Log Value" width="90" x="380" y="30">
                <parameter key="macro_name" value="Sub_Count"/>
              </operator>
              <operator activated="true" class="log" compatibility="5.1.001" expanded="true" height="76" name="Log" width="90" x="581" y="30">
                <list key="log">
                  <parameter key="Filter" value="operator.Provide Macro as Log Value.value.macro_value"/>
                </list>
              </operator>
              <connect from_port="input 1" to_op="Filter Example Range" to_port="example set input"/>
              <connect from_op="Filter Example Range" from_port="example set output" to_op="Extract Macro (2)" to_port="example set"/>
              <connect from_op="Extract Macro (2)" from_port="example set" to_op="Provide Macro as Log Value" to_port="through 1"/>
              <connect from_op="Provide Macro as Log Value" from_port="through 1" to_op="Log" to_port="through 1"/>
              <connect from_op="Log" 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="Retrieve" from_port="output" to_op="Extract Macro" to_port="example set"/>
          <connect from_op="Extract Macro" from_port="example set" to_op="Loop" to_port="input 1"/>
          <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>
  • mdcmdc Member Posts: 58 Maven
    Hi Haddock,

    Thanks for the reply. However, what I want is a little different. I want to perform the loop while a certain exampleset inside that loop is not empty. That means the loop stops when that exampleset is empty. It doesn't need the count of the exampleset. It looks to me that the operator Loop Until will do the trick. It checks an exampleset inside for criteria. But it also needs a performance input which is giving me an error (or bug).

    thanks again.
  • landland RapidMiner Certified Analyst, RapidMiner Certified Expert, Member Posts: 2,531 Unicorn
    Hi,

    you could use the "Extract Performance" Operator to extract a performance vector from your example set's properties.
    Even if you don't need it in the end, you can deliver this dummy performance object to the port to satisfy it's condition.

    But I guess you can use it to extract the number of examples as performance and use the conditions of Loop Until to abort if no examples are left.

    Greetings,
      Sebastian
Sign In or Register to comment.