🎉 🎉 RAPIDMINER 9.10 IS OUT!!! 🎉🎉

Download the latest version helping analytics teams accelerate time-to-value for streaming and IIOT use cases.

CLICK HERE TO DOWNLOAD

Generate Attribute for binomials

BartNBartN Member Posts: 18  Maven
edited August 2019 in Help
The "Generate Attributes" operator allows to define an if() statement as an expression on attributes that does not seem to work on binominals in Rapid 5.2.003

For example, the binominal attribute for a simple traffic light is color={RED, GREEN}, and i would like to generate a new attribute 'drive' with values {STOP, GO}.
The Generate Attributes operator has a new attribute = "drive" and function expression = "if(color=RED,STOP,GO)".

Running this results in a Process Failed window with the message "Generation exception:"No such attribute: "STOP"
An operator failed to generate a new attribute, macro or other object which is calculated on the fly. Reason: No such attribute: 'STOP'"

Since the on-line help does not exclude binomials attributes, i suppose is should work, somehow.
Does anyone know how to?

Answers

  • haddockhaddock Member Posts: 849  Maven
    Hi Bart,

    I think you need a double equals (==) and to quote the values, like this...
    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    <process version="5.2.003">
      <context>
        <input/>
        <output/>
        <macros/>
      </context>
      <operator activated="true" class="process" compatibility="5.2.003" expanded="true" name="Process">
        <process expanded="true" height="179" width="480">
          <operator activated="true" class="generate_data" compatibility="5.2.003" expanded="true" height="60" name="Generate Data" width="90" x="40" y="53"/>
          <operator activated="true" class="discretize_by_bins" compatibility="5.2.003" expanded="true" height="94" name="Discretize" width="90" x="183" y="51">
            <parameter key="range_name_type" value="short"/>
          </operator>
          <operator activated="true" class="nominal_to_binominal" compatibility="5.2.003" expanded="true" height="94" name="Nominal to Binominal" width="90" x="313" y="75"/>
          <operator activated="true" class="generate_attributes" compatibility="5.2.003" expanded="true" height="76" name="Generate Attributes" width="90" x="490" y="73">
            <list key="function_descriptions">
              <parameter key="nu" value="if(att5==&quot;range1&quot;,true,false)"/>
            </list>
          </operator>
          <connect from_op="Generate Data" from_port="output" to_op="Discretize" to_port="example set input"/>
          <connect from_op="Discretize" from_port="example set output" to_op="Nominal to Binominal" to_port="example set input"/>
          <connect from_op="Nominal to Binominal" from_port="example set 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>
    I recommend the little wizard that helps with the regex in the generating operator, it sure helps..

    Good weekend

  • BartNBartN Member Posts: 18  Maven
    Hi Captain,

    Thanks for the help. The quotes solves the problem: if(color=="RED","STOP","GO")

    The '==' was just a typo in my post indeed.

    Interesting why the error was generated for the second erroneous value (STOP) and not for the first in the comparison operation (RED).

    The wizard may be useful but i did not bother to define the value type of the import data, and apparently the wizard ignores the binominal values in the Attributes list, and also does not mind whether you use quotes or not (RED or "RED" are both OK).
Sign In or Register to comment.