Math formula operator for RM?

holger
holger New Altair Community Member
edited November 5 in Community Q&A
Hi,

for Knime there's a operator called "Math Formula" ( http://www.knime.org/downloads/extensions ), which allows you to evaluate free-form mathematical expressions. The result is appended as a new column to the input table.

Is there something similar for rm5? If not: how can I calculate a simple ratio, sum or product of 2 (or more) columns?

Best, Holger
Tagged:

Answers

  • IngoRM
    IngoRM New Altair Community Member
    Hi Holger,

    sure, an operator like this is of course part of RapidMiner and called "Generate Attributes" in RapidMiner 5.

    You can create multiple attributes at once and you can even re-use attributes which just have been created. The documentation of the operator gives you complete overview of all supported functions. By the way, "Generate Attributes" also support conditions and even nominal values like in the following example:

    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    <process version="5.0">
      <context>
        <input>
          <location/>
        </input>
        <output>
          <location/>
          <location/>
        </output>
        <macros/>
      </context>
      <operator activated="true" class="process" expanded="true" name="Process">
        <process expanded="true" height="251" width="413">
          <operator activated="true" class="generate_data" expanded="true" height="60" name="Generate Data" width="90" x="153" y="191"/>
          <operator activated="true" class="generate_attributes" expanded="true" height="76" name="Generate Attributes" width="90" x="313" y="165">
            <list key="function_descriptions">
              <parameter key="new_sum" value="att1 + att2"/>
              <parameter key="new_product" value="att2 * 4 * att5"/>
              <parameter key="new_condition" value="if (round(new_sum) &gt; 5, &quot;large&quot;, str(new_product))"/>
            </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>
    Cheers,
    Ingo
  • holger
    holger New Altair Community Member
    Hi Ingo,

    Thanks a lot for your fast response. I've played around with it, and imho its still lacks behind the functionality of the knime-variant. The problem is that when configuring "Generate Attributes" I have to know and to type the attribute-names.

    In Knime this solved more elegantly by showing the list of attributes on the left. By double-clicking on of them the name becomes automatically inserted into the attribute-generation function being currently edited.

    IMHO at least showing the attribute-names in the "Generate Attributes"-configuration-dialog (including a working copy-command for them) is a must to make the creation of new attributes comfortable. What do you think?

    I could submit a patch if you would like to have it, but are short on dev-manpower.

    Cheers, Holger
  • IngoRM
    IngoRM New Altair Community Member
    Hi Holger,

    yes, I know:

    http://bugs.rapid-i.com/show_bug.cgi?id=135

    (submitted by myself  ;) )


    In addition to the attribute names, I would also like to see macros and of course all expressions, so that the graphical element for this resemles a calculator with buttons for expressions and lists for names and macros. However, there are two things which are missing for that:
    • a propagation of macros throughout the process,
    • an information provider for the existing functions and their arguments (number of arguments, types etc.)
    I agree that a list of attribute names would already be possible and we can try to add it already to RapidMiner 5. The full calculator will be postponed to RM 5.1 - as well as a more comfortable editor for expressions for example filtering (see http://bugs.rapid-i.com/show_bug.cgi?id=142 ). Those two operators are still more in the old RapidMiner 2.1 style  ;D

    We would highly appreciate a patch for providing at least the attribute names for this GUI element if you would provide one. Although please have in mind that it is very likely that we have to revisit the element for RM 5.1 in order to incorporate the available functions and the macros as well. The bug fixes for the final release of RM 5 currently burn a lot of our developer resources and there will only be little place for further feature enhancements from our side right now, sorry. But of course we should manage to incorporate a patch - especially if it comes from an experienced developer, so yes, please, send us a patch to

    developers@rapidminer.com

    All the best and thanks,
    Ingo