com.rapidminer.tools.math.function
Class ExpressionParser

java.lang.Object
  extended by com.rapidminer.tools.math.function.ExpressionParser

public class ExpressionParser
extends java.lang.Object

This class can be used as expression parser in order to generate new attributes. The parser constructs new attributes from the attributes of the input example set.

The following operators are supported:

The following log and exponential functions are supported:

The following trigonometric functions are supported:

The following statistical functions are supported:

The following miscellaneous functions are supported:

The following miscellaneous functions are supported:

Beside those operators and functions, this operator also supports the constants pi and e if this is indicated by the corresponding parameter (default: true). You can also use strings in formulas (for example in a conditioned if-formula) but the string values have to be enclosed in double quotes.

Please note that there are some restrictions for the attribute names in order to let this operator work properly:

If these conditions are not fulfilled, the names must be changed beforehand, for example with the ChangeAttributeName operator.


Examples:
a1+sin(a2*a3)
if (att1>5, att2*att3, -abs(att1))

Author:
Ingo Mierswa

Constructor Summary
ExpressionParser(boolean useStandardConstants)
           
ExpressionParser(boolean useStandardConstants, Process process)
          This constructor allows additional functions if called within a process.
 
Method Summary
 void addAttribute(ExampleSet exampleSet, java.lang.String name, java.lang.String function)
          Iterates over the ExampleSet, interprets attributes as variables, evaluates the function and creates a new attribute with the given name that takes the expression's value.
 void addMacro(MacroHandler macroHandler, java.lang.String name, java.lang.String function)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ExpressionParser

public ExpressionParser(boolean useStandardConstants)

ExpressionParser

public ExpressionParser(boolean useStandardConstants,
                        Process process)
This constructor allows additional functions if called within a process.

Method Detail

addMacro

public void addMacro(MacroHandler macroHandler,
                     java.lang.String name,
                     java.lang.String function)
              throws GenerationException
Throws:
GenerationException

addAttribute

public void addAttribute(ExampleSet exampleSet,
                         java.lang.String name,
                         java.lang.String function)
                  throws GenerationException
Iterates over the ExampleSet, interprets attributes as variables, evaluates the function and creates a new attribute with the given name that takes the expression's value. The type of the attribute depends on the expression type and is Ontology.NOMINAL for strings, Ontology.NUMERICAL for reals and complex numbers and Ontology.BINOMINAL with values "true" and "false" for booleans.

Throws:
GenerationException


Copyright © 2001-2009 by Rapid-I