Due to recent updates, all users are required to create an Altair One account to login to the RapidMiner community. Click the Register button to create your account using the same email that you have previously used to login to the RapidMiner community. This will ensure that any previously created content will be synced to your Altair One account. Once you login, you will be asked to provide a username that identifies you to other Community users. Email us at Community with questions.

Loop until an other parameter changes

e_lisae_lisa Member Posts: 1 Learner I
Hello,

I have only been working with RapidMiner for a short time and would like to try the following, which I am not getting communicated properly to RM so far. Can anyone help or have a similar process?

I have various input data, as well as various input pressure values. Output so far is "okay", or "not okay". Now I want to turn the whole thing around and iterate the pressure values until it changes from "not okay" to "okay". The maximum possible pressure (still "okay") should be output in the end.

How can I proceed here? I have already tried various loop operations, but have not been successful so far.

Greetings Elisa

Answers

  • jwpfaujwpfau Employee, Member Posts: 303 RM Engineering
    Hi Elisa,

    catching on your loop idea you could Branch to Throw Exception if "not okay" otherwise Remember the value.
    A layer above the loop you could use Handle Exception and Recall the last valid value.

    But if the data is known beforehand there is probably a more straightforward solution that doesn't require a loop.

    Greetings,
    Jonas
  • CKönigCKönig Employee, Member Posts: 70 RM Team Member
    edited May 2023
    Hi Elisa,
    welcome to the RapidMiner community.

    I'm not 100% sure I understand your question. If you want to get the maximum pressure, where the status is still okay, you can first use "Filter Examples" and then "Aggregate" to find the maximum pressure value just for examples with status "okay".

    If you want to do something more advanced, the operator "Differentiate" can detect changes in an attribute.

    I created an example process, which probably illustrates this better:
    <?xml version="1.0" encoding="UTF-8"?><process version="9.10.013">
      <context>
        <input/>
        <output/>
        <macros/>
      </context>
      <operator activated="true" class="process" compatibility="9.10.013" 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="subprocess" compatibility="9.10.013" expanded="true" height="82" name="Subprocess" width="90" x="45" y="187">
            <process expanded="true">
              <operator activated="true" class="utility:create_exampleset" compatibility="9.10.013" expanded="true" height="68" name="Create ExampleSet" width="90" x="45" y="34">
                <parameter key="generator_type" value="attribute functions"/>
                <parameter key="number_of_examples" value="100"/>
                <parameter key="use_stepsize" value="false"/>
                <list key="function_descriptions">
                  <parameter key="status" value="if(rand()&gt;0.5, &quot;okay&quot;, &quot;not okay&quot;)"/>
                  <parameter key="pressure" value="ceil(rand()*100)"/>
                </list>
                <parameter key="add_id_attribute" value="false"/>
                <list key="numeric_series_configuration"/>
                <list key="date_series_configuration"/>
                <list key="date_series_configuration (interval)"/>
                <parameter key="date_format" value="yyyy-MM-dd HH:mm:ss"/>
                <parameter key="time_zone" value="SYSTEM"/>
                <parameter key="column_separator" value=","/>
                <parameter key="parse_all_as_nominal" value="false"/>
                <parameter key="decimal_point_character" value="."/>
                <parameter key="trim_attribute_names" value="true"/>
              </operator>
              <operator activated="true" class="blending:sort" compatibility="9.10.013" expanded="true" height="82" name="Sort" width="90" x="179" y="34">
                <list key="sort_by">
                  <parameter key="pressure" value="ascending"/>
                </list>
              </operator>
              <operator activated="true" class="remove_duplicates" compatibility="9.10.013" expanded="true" height="103" name="Remove Duplicates" width="90" x="313" y="34">
                <parameter key="attribute_filter_type" value="single"/>
                <parameter key="attribute" value="pressure"/>
                <parameter key="attributes" value=""/>
                <parameter key="use_except_expression" value="false"/>
                <parameter key="value_type" value="attribute_value"/>
                <parameter key="use_value_type_exception" value="false"/>
                <parameter key="except_value_type" value="time"/>
                <parameter key="block_type" value="attribute_block"/>
                <parameter key="use_block_type_exception" value="false"/>
                <parameter key="except_block_type" value="value_matrix_row_start"/>
                <parameter key="invert_selection" value="false"/>
                <parameter key="include_special_attributes" value="false"/>
                <parameter key="treat_missing_values_as_duplicates" value="false"/>
              </operator>
              <connect from_op="Create ExampleSet" from_port="output" to_op="Sort" to_port="example set input"/>
              <connect from_op="Sort" from_port="example set output" to_op="Remove Duplicates" to_port="example set input"/>
              <connect from_op="Remove Duplicates" from_port="example set output" to_port="out 1"/>
              <portSpacing port="source_in 1" spacing="0"/>
              <portSpacing port="sink_out 1" spacing="0"/>
              <portSpacing port="sink_out 2" spacing="0"/>
            </process>
            <description align="center" color="transparent" colored="false" width="126">Generate Example Data</description>
          </operator>
          <operator activated="true" class="multiply" compatibility="9.10.013" expanded="true" height="103" name="Multiply" width="90" x="179" y="187"/>
          <operator activated="true" class="filter_examples" compatibility="9.10.013" expanded="true" height="103" name="Filter Examples" width="90" x="313" y="85">
            <parameter key="parameter_expression" value=""/>
            <parameter key="condition_class" value="custom_filters"/>
            <parameter key="invert_filter" value="false"/>
            <list key="filters_list">
              <parameter key="filters_entry_key" value="status.equals.okay"/>
            </list>
            <parameter key="filters_logic_and" value="true"/>
            <parameter key="filters_check_metadata" value="true"/>
            <description align="center" color="transparent" colored="false" width="126">Just keep data where status is &amp;quot;okay&amp;quot;</description>
          </operator>
          <operator activated="true" class="generate_attributes" compatibility="9.10.013" expanded="true" height="82" name="Generate Attributes" width="90" x="313" y="391">
            <list key="function_descriptions">
              <parameter key="status_numerical" value="if(status==&quot;okay&quot;, 1, 0)"/>
            </list>
            <parameter key="keep_all" value="true"/>
            <description align="center" color="transparent" colored="false" width="126">Add status as numerical attribute</description>
          </operator>
          <operator activated="true" class="time_series:differentiation" compatibility="9.10.009" expanded="true" height="68" name="Differentiate" width="90" x="447" y="391">
            <parameter key="attribute_filter_type" value="single"/>
            <parameter key="attribute" value="status_numerical"/>
            <parameter key="attributes" value=""/>
            <parameter key="use_except_expression" value="false"/>
            <parameter key="value_type" value="numeric"/>
            <parameter key="use_value_type_exception" value="false"/>
            <parameter key="except_value_type" value="real"/>
            <parameter key="block_type" value="value_series"/>
            <parameter key="use_block_type_exception" value="false"/>
            <parameter key="except_block_type" value="value_series_end"/>
            <parameter key="invert_selection" value="false"/>
            <parameter key="include_special_attributes" value="false"/>
            <parameter key="overwrite_attributes" value="false"/>
            <parameter key="new_attributes_postfix" value="_differentiated"/>
            <parameter key="lag" value="1"/>
            <parameter key="differentiation_method" value="subtraction"/>
            <description align="center" color="transparent" colored="false" width="126">Detect changes in status&lt;br/&gt;&lt;br/&gt;(this uses the current order of examples, make sure the example set is correctly sorted)</description>
          </operator>
          <operator activated="true" class="filter_examples" compatibility="9.10.013" expanded="true" height="103" name="Filter Examples (2)" width="90" x="581" y="391">
            <parameter key="parameter_expression" value=""/>
            <parameter key="condition_class" value="custom_filters"/>
            <parameter key="invert_filter" value="false"/>
            <list key="filters_list">
              <parameter key="filters_entry_key" value="status_numerical_differentiated.eq.1"/>
            </list>
            <parameter key="filters_logic_and" value="true"/>
            <parameter key="filters_check_metadata" value="true"/>
            <description align="center" color="transparent" colored="false" width="126">only keep examples, where status changed from &amp;quot;not okay&amp;quot; to &amp;quot;okay&amp;quot;</description>
          </operator>
          <operator activated="true" class="blending:sort" compatibility="9.10.013" expanded="true" height="82" name="Sort (2)" width="90" x="715" y="391">
            <list key="sort_by">
              <parameter key="pressure" value="descending"/>
            </list>
            <description align="center" color="transparent" colored="false" width="126">sort by pressure value, descending</description>
          </operator>
          <operator activated="true" class="filter_example_range" compatibility="9.10.013" expanded="true" height="82" name="Filter Example Range" width="90" x="849" y="391">
            <parameter key="first_example" value="1"/>
            <parameter key="last_example" value="1"/>
            <parameter key="invert_filter" value="false"/>
            <description align="center" color="transparent" colored="false" width="126">only keep highest pressure value</description>
          </operator>
          <operator activated="true" class="select_attributes" compatibility="9.10.013" expanded="true" height="82" name="Select Attributes" width="90" x="983" y="391">
            <parameter key="attribute_filter_type" value="subset"/>
            <parameter key="attribute" value=""/>
            <parameter key="attributes" value="status_numerical|status_numerical_differentiated"/>
            <parameter key="use_except_expression" value="false"/>
            <parameter key="value_type" value="attribute_value"/>
            <parameter key="use_value_type_exception" value="false"/>
            <parameter key="except_value_type" value="time"/>
            <parameter key="block_type" value="attribute_block"/>
            <parameter key="use_block_type_exception" value="false"/>
            <parameter key="except_block_type" value="value_matrix_row_start"/>
            <parameter key="invert_selection" value="true"/>
            <parameter key="include_special_attributes" value="false"/>
            <description align="center" color="transparent" colored="false" width="126">remove temporary attributes</description>
          </operator>
          <operator activated="true" class="aggregate" compatibility="9.10.013" expanded="true" height="82" name="Aggregate" width="90" x="447" y="85">
            <parameter key="use_default_aggregation" value="false"/>
            <parameter key="attribute_filter_type" value="all"/>
            <parameter key="attribute" value=""/>
            <parameter key="attributes" value=""/>
            <parameter key="use_except_expression" value="false"/>
            <parameter key="value_type" value="attribute_value"/>
            <parameter key="use_value_type_exception" value="false"/>
            <parameter key="except_value_type" value="time"/>
            <parameter key="block_type" value="attribute_block"/>
            <parameter key="use_block_type_exception" value="false"/>
            <parameter key="except_block_type" value="value_matrix_row_start"/>
            <parameter key="invert_selection" value="false"/>
            <parameter key="include_special_attributes" value="false"/>
            <parameter key="default_aggregation_function" value="average"/>
            <list key="aggregation_attributes">
              <parameter key="pressure" value="maximum"/>
              <parameter key="status" value="mode"/>
            </list>
            <parameter key="group_by_attributes" value=""/>
            <parameter key="count_all_combinations" value="false"/>
            <parameter key="only_distinct" value="false"/>
            <parameter key="ignore_missings" value="true"/>
            <description align="center" color="transparent" colored="false" width="126">get the maximum pressure for all values</description>
          </operator>
          <operator activated="true" class="rename_by_replacing" compatibility="9.10.013" expanded="true" height="82" name="Rename by Replacing" width="90" x="581" y="85">
            <parameter key="attribute_filter_type" value="all"/>
            <parameter key="attribute" value=""/>
            <parameter key="attributes" value=""/>
            <parameter key="use_except_expression" value="false"/>
            <parameter key="value_type" value="attribute_value"/>
            <parameter key="use_value_type_exception" value="false"/>
            <parameter key="except_value_type" value="time"/>
            <parameter key="block_type" value="attribute_block"/>
            <parameter key="use_block_type_exception" value="false"/>
            <parameter key="except_block_type" value="value_matrix_row_start"/>
            <parameter key="invert_selection" value="false"/>
            <parameter key="include_special_attributes" value="false"/>
            <parameter key="replace_what" value=".*\((.*)\)"/>
            <parameter key="replace_by" value="$1"/>
            <description align="center" color="transparent" colored="false" width="126">optional: rename attributes back for clarity</description>
          </operator>
          <connect from_op="Subprocess" from_port="out 1" to_op="Multiply" to_port="input"/>
          <connect from_op="Multiply" from_port="output 1" to_op="Filter Examples" to_port="example set input"/>
          <connect from_op="Multiply" from_port="output 2" to_op="Generate Attributes" to_port="example set input"/>
          <connect from_op="Filter Examples" from_port="example set output" to_op="Aggregate" to_port="example set input"/>
          <connect from_op="Generate Attributes" from_port="example set output" to_op="Differentiate" to_port="example set"/>
          <connect from_op="Differentiate" from_port="example set" to_op="Filter Examples (2)" to_port="example set input"/>
          <connect from_op="Filter Examples (2)" from_port="example set output" to_op="Sort (2)" to_port="example set input"/>
          <connect from_op="Sort (2)" from_port="example set output" to_op="Filter Example Range" to_port="example set input"/>
          <connect from_op="Filter Example Range" from_port="example set output" to_op="Select Attributes" to_port="example set input"/>
          <connect from_op="Select Attributes" from_port="example set output" to_port="result 2"/>
          <connect from_op="Aggregate" from_port="example set output" to_op="Rename by Replacing" to_port="example set input"/>
          <connect from_op="Rename by Replacing" from_port="example set output" 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"/>
          <portSpacing port="sink_result 3" spacing="0"/>
          <description align="center" color="yellow" colored="false" height="260" resized="true" width="419" x="294" y="10">Simple way:&lt;br/&gt;get the maximum value by aggregation</description>
          <description align="center" color="yellow" colored="false" height="360" resized="true" width="799" x="294" y="292">More complex:&lt;br&gt;detect changes in an attribute</description>
        </process>
      </operator>
    </process>

    If this doesn't help you, please give an example of your input data and expected output.

    Have a nice day,
    Christian
Sign In or Register to comment.