"How to filter examples with attributes with same value"

bzavalabzavala Member Posts: 19 Contributor II
edited June 2019 in Help
Hi! I need to establish a filter condition on my example set but I dont know how to do it. I need to filter examples who has the same value on att 1 and att2. The filter examples box dont have the option to establish that condition, only allows fixing the values of the attributes.  I thought I could do it by generating a new attribute that was the subtraction between att1 and att2 and filtering by conditioning that the new attribute has to be zero, but att1 and att2 are nominal ones so Im not allowed to do that. I wish you could help me, thanks you in advance.


EDIT: I realized that actually there is an option to set conditions over several attributes. However, when I run the process, I get a message error that says this:


"Cannot instantiate 'expression': Expression 'Material=Material2' does not evaluate to a boolean value!
Some operators instantiate classes specified by the user. This may cause errors for mainly two reasons: The class cannot be found because it is not in the classpath or misspelled or the classes constructor or initializer throws an exception. Always use the fully qualified classnames.

Reason:Expression 'Material'='Material2' does not evaluate a boolean value!"

I dont understand anything about what it says, what does that mean? How can I solve it? Thanks you
Tagged:

Answers

  • DocMusherDocMusher Member Posts: 333 Unicorn
    What about using strings to compare the 2 attributes (by generating a new attribute)?
    Sven
  • earmijoearmijo Member Posts: 270 Unicorn
    It is very easy to do. Take a look at this process:

    [tt]<?xml version="1.0" encoding="UTF-8" standalone="no"?>
    <process version="6.5.002">
      <context>
        <input/>
        <output/>
        <macros/>
      </context>
      <operator activated="true" class="process" compatibility="6.5.002" expanded="true" name="Process">
        <process expanded="true">
          <operator activated="true" class="retrieve" compatibility="6.5.002" expanded="true" height="60" name="Retrieve test1" width="90" x="45" y="75">
            <parameter key="repository_entry" value="//Clases/test1"/>
          </operator>
          <operator activated="true" class="generate_attributes" compatibility="6.5.002" expanded="true" height="76" name="Generate Attributes" width="90" x="179" y="30">
            <list key="function_descriptions">
              <parameter key="att3" value="if(att1==att2,1,0)"/>
            </list>
          </operator>
          <operator activated="true" class="filter_examples" compatibility="6.5.002" expanded="true" height="94" name="Filter Examples" width="90" x="380" y="30">
            <parameter key="invert_filter" value="true"/>
            <list key="filters_list">
              <parameter key="filters_entry_key" value="att3.eq.1"/>
            </list>
          </operator>
          <connect from_op="Retrieve test1" 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_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>
    [/tt]

    The dataset I read is:

    att1 att2
    new old
    old old
    new old
    old new
    new new
    old new

  • bzavalabzavala Member Posts: 19 Contributor II
    Thanks you very much for your help, I used it and it worked :) Thanks again
Sign In or Register to comment.