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
- See Also:
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic 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.getFieldDef
(String attName) Return the named attribute from the list of reference fields.int
getFieldDefIndex
(String attName) 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 usetoString()
-
Constructor Details
-
Expression
-
-
Method Details
-
setFieldDefs
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
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
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
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 expressionopType
- 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 getexpression
- the Node containing the expressionopType
- 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
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
-
getOptype
Get the optype of the result of applying this Expression.- Returns:
- the optype of the result of applying this Expression
-
toString
-
toString
-