Package weka.core.pmml

# Class Expression

java.lang.Object
weka.core.pmml.Expression

All Implemented Interfaces:
  `Serializable`

Direct Known Subclasses:
  `Constant`, `Discretize`, `FieldRef`, `NormContinuous`, `NormDiscrete`

public abstract class Expression extends Object implements Serializable

See Also:
  - Serialized Form

## Constructor Summary

Constructors
Constructor
Description
`Expression(FieldMetaInfo.Optype opType, ArrayList<Attribute> fieldDefs)`

## Method Summary

Modifier and Type
Method
Description
`static Expression`
`getExpression(String name, Node expression, FieldMetaInfo.Optype opType, ArrayList<Attribute> fieldDefs, weka.core.pmml.TransformationDictionary transDict)`
Static factory method that returns a subclass of Expression that encapsulates the type of expression supplied as an argument.
`static Expression`
`getExpression(Node container, FieldMetaInfo.Optype opType, ArrayList<Attribute> fieldDefs, weka.core.pmml.TransformationDictionary transDict)`
Static factory method that returns a subclass of Expression that encapsulates the type of expression contained in the Element supplied.
`Attribute`
`getFieldDef(String attName)`
Return the named attribute from the list of reference fields.
`int`
`getFieldDefIndex(String attName)`
`FieldMetaInfo.Optype`
`getOptype()`
Get the optype of the result of applying this Expression.
`abstract double`
`getResult(double[] incoming)`
Get the result of evaluating the expression.
`abstract String`
`getResultCategorical(double[] incoming)`
Gets the result of evaluating the expression when the optype is categorical or ordinal as the actual String value.
`double`
`getResultContinuous(double[] incoming)`
Get the result of evaluating the expression for continuous optype.
`void`
`setFieldDefs(ArrayList<Attribute> fieldDefs)`
Set the field definitions for this Expression to use
`String`
`toString()`
`String`
`toString(String pad)`

### Methods inherited from class java.lang.Object

`equals, getClass, hashCode, notify, notifyAll, wait, wait, wait`

## Constructor Details

### Expression

public Expression(FieldMetaInfo.Optype opType, ArrayList<Attribute> fieldDefs)

## Method Details

### setFieldDefs

public void setFieldDefs(ArrayList<Attribute> fieldDefs) throws Exception
Set the field definitions for this Expression to use

Parameters:
  `fieldDefs` - the field definitions to use
Throws:
  `Exception` - if there is a problem setting the field definitions

### getResult

public abstract double getResult(double[] incoming) throws Exception
Get the result of evaluating the expression. In the case of a continuous optype, a real number is returned; in the case of a categorical/ordinal optype, the index of the nominal value is returned as a double.

Parameters:
  `incoming` - the incoming parameter values
Returns:
  the result of evaluating the expression
Throws:
  `Exception` - if there is a problem computing the result

### getResultContinuous

public double getResultContinuous(double[] incoming) throws Exception
Get the result of evaluating the expression for continuous optype. Is the same as calling getResult() when the optype is continuous.

Parameters:
  `incoming` - the incoming parameter values mining schema
Returns:
  the result of evaluating the expression.
Throws:
  `Exception` - if the optype is not continuous.

### getResultCategorical

public abstract String getResultCategorical(double[] incoming) throws Exception
Gets the result of evaluating the expression when the optype is categorical or ordinal as the actual String value.

Parameters:
  `incoming` - the incoming parameter values
Returns:
  the result of evaluating the expression
Throws:
  `Exception` - if the optype is continuous

### getExpression

public static Expression getExpression(Node container, FieldMetaInfo.Optype opType, ArrayList<Attribute> fieldDefs, weka.core.pmml.TransformationDictionary transDict) throws Exception
Static factory method that returns a subclass of Expression that encapsulates the type of expression contained in the Element supplied. Assumes that there is just one expression contained in the supplied Element.

Parameters:
  `container` - the Node containing the expression
  `opType` - the optype of the value returned by this Expression.
  `fieldDefs` - an ArrayList of Attributes for the fields that this Expression may need to access Since Expressions are children of either DerivedFields or DefineFuntions, they will have the same optype as their parent.
  `transDict` - the TransformationDictionary (may be null if there is no dictionary)
Returns:
  an Expression object or null if there is no known expression in the container
Throws:
  `Exception` - for unsupported Expression types

### getExpression

public static Expression getExpression(String name, Node expression, FieldMetaInfo.Optype opType, ArrayList<Attribute> fieldDefs, weka.core.pmml.TransformationDictionary transDict) throws Exception
Static factory method that returns a subclass of Expression that encapsulates the type of expression supplied as an argument.

Parameters:
  `name` - the name of the Expression to get
  `expression` - the Node containing the expression
  `opType` - the optype of the value returned by this Expression.
  `fieldDefs` - an ArrayList of Attributes for the fields that this Expression may need to access Since Expressions are children of either DerivedFields or DefineFuntions, they will have the same optype as their parent.
  `transDict` - the TransformationDictionary (may be null if there is no dictionary)
Returns:
  an Expression object or null if there is no known expression in the container
Throws:
  `Exception` - for unsupported Expression types

### getFieldDef

public Attribute getFieldDef(String attName)
Return the named attribute from the list of reference fields.

Parameters:
  `attName` - the name of the attribute to retrieve
Returns:
  the named attribute (or null if it can't be found).

### getFieldDefIndex

public int getFieldDefIndex(String attName)

### getOptype

public FieldMetaInfo.Optype getOptype()
Get the optype of the result of applying this Expression.

Returns:
  the optype of the result of applying this Expression

### toString

public String toString()

Overrides:
  `toString` in class `Object`

### toString

public String toString(String pad)