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.

[SOLVED] Find minimum value of column

bperqukubperquku Member Posts: 6 Contributor II
edited November 2018 in Help
Hello,

I have a simple scenario where I want to to apply a formula on generated attribute. I simplified the workflow to generate 10 samples and then generate attribute which will hold minimum value.

<operator activated="true" class="process" compatibility="5.3.000" expanded="true" name="Process">
   <process expanded="true" height="411" width="762">
     <operator activated="true" class="generate_data" compatibility="5.3.000" expanded="true" height="60" name="Generate Data" width="90" x="45" y="75">
       <parameter key="number_examples" value="10"/>
       <parameter key="number_of_attributes" value="1"/>
     </operator>
     <operator activated="true" class="generate_attributes" compatibility="5.3.000" expanded="true" height="76" name="Generate Attributes" width="90" x="246" y="120">
       <list key="function_descriptions">
         <parameter key="Min" value="min(att1)"/>
       </list>
     </operator>
     <connect from_op="Generate Data" from_port="output" to_op="Generate Attributes" to_port="example set input"/>
     <connect from_op="Generate Attributes" 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"/>
   </process>
 </operator>
In the result below, the last colum is evaluated as min(att1). Why in last column is not displayed the minimum value?
1 0.8633563476940593 2.467612009982549 2.467612009982549
2 0.06876328426040379 1.2924127751628518 1.2924127751628518
3 0.4846603438968893 -5.589923335093689 -5.589923335093689
4 0.9684928217146895 -6.350916620988873 -6.350916620988873
5 0.9366372796859641 1.2414027313347589 1.2414027313347589
6 0.692586106000668 -8.767780617998435 -8.767780617998435
7 0.40107538634598017 -5.189688812982061 -5.189688812982061
8 0.029369504278170422 -6.224623149327426 -6.224623149327426
9 0.07736300953569464 -7.153585749698594 -7.153585749698594
10 0.2802396559329807 -4.695913351021728 -4.695913351021728

Thanks

Answers

  • awchisholmawchisholm RapidMiner Certified Expert, Member Posts: 458 Unicorn
    Hello

    The generate attributes operator does an implicit loop over all the examples within an example set. The function sees the attribute value within the context of a "current example".  The function finds the minimum of the attributes passed to it. This means the minimum of an attribute will always be the attribute itself for the current example if it is the only argument to the function.

    I've attached a process that uses the Extract Macro operator that might do what you want.
    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    <process version="5.3.007">
      <context>
        <input/>
        <output/>
        <macros/>
      </context>
      <operator activated="true" class="process" compatibility="5.3.007" expanded="true" name="Process">
        <process expanded="true">
          <operator activated="true" class="generate_data" compatibility="5.3.007" expanded="true" height="60" name="Generate Data" width="90" x="45" y="75">
            <parameter key="number_examples" value="10"/>
            <parameter key="number_of_attributes" value="1"/>
          </operator>
          <operator activated="true" class="extract_macro" compatibility="5.3.007" expanded="true" height="60" name="Extract Macro" width="90" x="179" y="75">
            <parameter key="macro" value="minatt1"/>
            <parameter key="macro_type" value="statistics"/>
            <parameter key="statistics" value="min"/>
            <parameter key="attribute_name" value="att1"/>
            <list key="additional_macros"/>
          </operator>
          <operator activated="true" class="generate_attributes" compatibility="5.3.007" expanded="true" height="76" name="Generate Attributes" width="90" x="313" y="75">
            <list key="function_descriptions">
              <parameter key="Min" value="%{minatt1}"/>
            </list>
          </operator>
          <connect from_op="Generate Data" from_port="output" to_op="Extract Macro" to_port="example set"/>
          <connect from_op="Extract Macro" from_port="example set" to_op="Generate Attributes" to_port="example set input"/>
          <connect from_op="Generate Attributes" 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"/>
        </process>
      </operator>
    </process>
    regards

    Andrew
  • bperqukubperquku Member Posts: 6 Contributor II
    Thank you Andrew.
Sign In or Register to comment.