All Packages  Class Hierarchy  This Package  Previous  Next  Index  WEKA's home

Class weka.filters.AttributeExpressionFilter

java.lang.Object
   |
   +----weka.filters.Filter
           |
           +----weka.filters.AttributeExpressionFilter

public class AttributeExpressionFilter
extends Filter
implements OptionHandler
Applys a mathematical expression involving attributes and numeric constants to a dataset. A new attribute is appended after the last attribute that contains the result of applying the expression. Supported operators are: +, -, *, /, ^, log, abs, cos, exp, sqrt, floor, ceil, rint, tan, sin, (, ). Attributes are specified by prefixing with 'a', eg. a7 is attribute number 7 (starting from 1).

Valid filter-specific options are:

-E expression
Specify the expression to apply. Eg. a1^2*a5/log(a7*4.0).

-N name
Specify a name for the new attribute. Default is to name it with the expression provided with the -E option.

-D
Debug. Names the attribute with the postfix parse of the expression.

Author:
Mark Hall (mhall@cs.waikato.ac.nz)

Constructor Index

 o AttributeExpressionFilter()

Method Index

 o debugTipText()
Returns the tip text for this property
 o expressionTipText()
Returns the tip text for this property
 o getDebug()
Gets whether debug is set
 o getExpression()
Get the expression
 o getName()
Returns the name of the new attribute
 o getOptions()
Gets the current settings of the filter.
 o globalInfo()
Returns a string describing this filter
 o input(Instance)
Input an instance for filtering.
 o listOptions()
Returns an enumeration describing the available options
 o main(String[])
Main method for testing this class.
 o nameTipText()
Returns the tip text for this property
 o setDebug(boolean)
Set debug mode.
 o setExpression(String)
Set the expression to apply
 o setInputFormat(Instances)
Sets the format of the input instances.
 o setName(String)
Set the name for the new attribute.
 o setOptions(String[])
Parses a list of options for this object.

Constructors

 o AttributeExpressionFilter
 public AttributeExpressionFilter()

Methods

 o globalInfo
 public String globalInfo()
Returns a string describing this filter

Returns:
a description of the filter suitable for displaying in the explorer/experimenter gui
 o listOptions
 public Enumeration listOptions()
Returns an enumeration describing the available options

Returns:
an enumeration of all the available options
 o setOptions
 public void setOptions(String options[]) throws Exception
Parses a list of options for this object. Valid options are:

-E expression
Specify the expression to apply. Eg. a1^2*a5/log(a7*4.0).

-N name
Specify a name for the new attribute. Default is to name it with the expression provided with the -E option.

-D
Debug. Names the attribute with the postfix parse of the expression.

Parameters:
options - the list of options as an array of strings
Throws: Exception
if an option is not supported
 o getOptions
 public String[] getOptions()
Gets the current settings of the filter.

Returns:
an array of strings suitable for passing to setOptions
 o nameTipText
 public String nameTipText()
Returns the tip text for this property

Returns:
tip text for this property suitable for displaying in the explorer/experimenter gui
 o setName
 public void setName(String name)
Set the name for the new attribute. The string "expression" can be used to make the name of the new attribute equal to the expression provided.

Parameters:
name - the name of the new attribute
 o getName
 public String getName()
Returns the name of the new attribute

Returns:
the name of the new attribute
 o debugTipText
 public String debugTipText()
Returns the tip text for this property

Returns:
tip text for this property suitable for displaying in the explorer/experimenter gui
 o setDebug
 public void setDebug(boolean d)
Set debug mode. Causes the new attribute to be named with the postfix parse of the expression

Parameters:
d - true if debug mode is to be used
 o getDebug
 public boolean getDebug()
Gets whether debug is set

Returns:
true if debug is set
 o expressionTipText
 public String expressionTipText()
Returns the tip text for this property

Returns:
tip text for this property suitable for displaying in the explorer/experimenter gui
 o setExpression
 public void setExpression(String expr)
Set the expression to apply

Parameters:
expr - a mathematical expression to apply
 o getExpression
 public String getExpression()
Get the expression

Returns:
the expression
 o setInputFormat
 public boolean setInputFormat(Instances instanceInfo) throws Exception
Sets the format of the input instances.

Parameters:
instanceInfo - an Instances object containing the input instance structure (any instances contained in the object are ignored - only the structure is required).
Returns:
true if the outputFormat may be collected immediately
Throws: Exception
if the format couldn't be set successfully
Overrides:
setInputFormat in class Filter
 o input
 public boolean input(Instance instance) throws Exception
Input an instance for filtering. Ordinarily the instance is processed and made available for output immediately. Some filters require all instances be read before producing output.

Parameters:
instance - the input instance
Returns:
true if the filtered instance may now be collected with output().
Throws: IllegalStateException
if no input format has been defined.
Throws: Exception
if there was a problem during the filtering.
Overrides:
input in class Filter
 o main
 public static void main(String args[])
Main method for testing this class.

Parameters:
args - should contain arguments to the filter: use -h for help

All Packages  Class Hierarchy  This Package  Previous  Next  Index  WEKA's home