[SOLVED] index function in rapid miner for interger values

sukhsukh Member Posts: 43 Contributor I
edited November 2018 in Help
Hi all,
i am working with the rapid miner. I need to find the which attribute has the maximum value from three attributes having integer values in it.
e.g. i have 3 attributes p1,p2,p3.
 pi=2, p2 = 3, p3 =6
in the new column i want ot have the name of the attribute having the maximum value.
in this case i need to have p3.
i have used max(p1,p2,p3). it gave me maximum value., but i want ot have the index value as p1,p2 or p3.

<code>
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<process version="6.3.000">
 <context>
   <input/>
   <output/>
   <macros/>
 </context>
 <operator activated="true" class="process" compatibility="6.3.000" expanded="true" name="Process">
   <process expanded="true">
     <operator activated="true" class="retrieve" compatibility="6.3.000" expanded="true" height="60" name="Retrieve" width="90" x="45" y="30">
       <parameter key="repository_entry" value="//Local Repository/CSVMaximum"/>
     </operator>
     <operator activated="true" class="generate_attributes" compatibility="6.3.000" expanded="true" height="76" name="Generate Attributes" width="90" x="179" y="30">
       <list key="function_descriptions">
         <parameter key="new" value="max(p1,p2,p3)"/>
       </list>
     </operator>
     <connect from_op="Retrieve" 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>
</process>
</code>

Answers

  • JEdwardJEdward RapidMiner Certified Analyst, RapidMiner Certified Expert, Member Posts: 563   Unicorn
    Very sure there's better ways of doing this, but this is one way off the top of my head. 
    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    <process version="6.4.000">
      <context>
        <input/>
        <output/>
        <macros/>
      </context>
      <operator activated="true" class="process" compatibility="6.4.000" expanded="true" name="Process">
        <process expanded="true">
          <operator activated="false" class="retrieve" compatibility="6.4.000" expanded="true" height="60" name="Retrieve" width="90" x="45" y="30">
            <parameter key="repository_entry" value="//Local Repository/CSVMaximum"/>
          </operator>
          <operator activated="true" class="generate_data" compatibility="6.4.000" expanded="true" height="60" name="Generate Data" width="90" x="45" y="120">
            <parameter key="target_function" value="sum"/>
            <parameter key="number_of_attributes" value="3"/>
          </operator>
          <operator activated="true" class="generate_attributes" compatibility="6.4.000" expanded="true" height="76" name="Generate Attributes" width="90" x="380" y="120">
            <list key="function_descriptions">
              <parameter key="new" value="if(att1==max(att1,att2,att3),&quot;att1&quot;,if(att2==max(att1,att2,att3),&quot;att2&quot;,if(att3==max(att1,att2,att3),&quot;att3&quot;,0)))"/>
            </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>
    </process>
  • sukhsukh Member Posts: 43 Contributor I
    Thanks alot Sir,
    you solved my problem.

    Regards:
    Sukh


Sign In or Register to comment.