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.

"Filtering attributes by logical expressions"

vme64vme64 Member Posts: 10 Contributor II
edited June 2019 in Help
Hello,

  I'd like to filter examples based on a logical condition, for example that attribute B is bigger than attribute A. I cannot do this with FilterExamples. Is there another operator that I am missing? Follows an example code.

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<process version="5.1.009">
  <context>
    <input/>
    <output/>
    <macros/>
  </context>
  <operator activated="true" class="process" compatibility="5.1.009" expanded="true" name="Process">
    <process expanded="true" height="351" width="874">
      <operator activated="true" class="generate_data_user_specification" compatibility="5.1.009" expanded="true" height="60" name="Generate Data by User Specification" width="90" x="45" y="30">
        <list key="attribute_values">
          <parameter key="a" value="1"/>
          <parameter key="b" value="2"/>
        </list>
        <list key="set_additional_roles"/>
      </operator>
      <operator activated="true" class="filter_examples" compatibility="5.1.009" expanded="true" height="76" name="Filter Examples" width="90" x="179" y="30">
        <parameter key="condition_class" value="attribute_value_filter"/>
        <parameter key="parameter_string" value="b &gt; a"/>
      </operator>
      <connect from_op="Generate Data by User Specification" from_port="output" to_op="Filter Examples" to_port="example set input"/>
      <connect from_op="Filter Examples" 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"/>
Best regards,

  Vinicius
Tagged:

Answers

  • Marco_BoeckMarco_Boeck Administrator, Moderator, Employee, Member, University Professor Posts: 1,996 RM Engineering
    Hi,

    you can do that by adding a Generate Attribute step:

    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    <process version="5.1.013">
      <context>
        <input/>
        <output/>
        <macros/>
      </context>
      <operator activated="true" class="process" compatibility="5.1.013" expanded="true" name="Process">
        <process expanded="true" height="351" width="874">
          <operator activated="true" class="generate_data_user_specification" compatibility="5.1.013" expanded="true" height="60" name="Generate Data by User Specification" width="90" x="45" y="30">
            <list key="attribute_values">
              <parameter key="a" value="1"/>
              <parameter key="b" value="2"/>
            </list>
            <list key="set_additional_roles"/>
          </operator>
          <operator activated="true" class="generate_attributes" compatibility="5.1.013" expanded="true" height="76" name="Generate Attributes" width="90" x="179" y="30">
            <list key="function_descriptions">
              <parameter key="toRemove" value="if(a&lt;b, true, false)"/>
            </list>
          </operator>
          <operator activated="true" class="filter_examples" compatibility="5.1.013" expanded="true" height="76" name="Filter Examples" width="90" x="313" y="30">
            <parameter key="condition_class" value="attribute_value_filter"/>
            <parameter key="parameter_string" value="toRemove != true"/>
          </operator>
          <operator activated="true" class="select_attributes" compatibility="5.1.013" expanded="true" height="76" name="Select Attributes" width="90" x="447" y="30">
            <parameter key="attribute_filter_type" value="single"/>
            <parameter key="attribute" value="toRemove"/>
            <parameter key="invert_selection" value="true"/>
          </operator>
          <connect from_op="Generate Data by User Specification" from_port="output" to_op="Generate Attributes" to_port="example set input"/>
          <connect from_op="Generate Attributes" from_port="example set output" to_op="Filter Examples" to_port="example set input"/>
          <connect from_op="Filter Examples" 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 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,
    Marco
  • vme64vme64 Member Posts: 10 Contributor II
    Thanks for the answer! I was just wondering if there was something more direct... Anyway, it works.

    Best regards,

      Vinicius
Sign In or Register to comment.