Package weka.filters.unsupervised.attribute

# Class MathExpression

java.lang.Object
weka.filters.Filter
weka.filters.unsupervised.attribute.PotentialClassIgnorer
weka.filters.unsupervised.attribute.MathExpression

All Implemented Interfaces:
  `Serializable`, `CapabilitiesHandler`, `OptionHandler`, `RevisionHandler`, `UnsupervisedFilter`

public class MathExpression extends PotentialClassIgnorer implements UnsupervisedFilter
Modify numeric attributes according to a given expression

Valid options are:

     -unset-class-temporarily
      Unsets the class index temporarily before the filter is
      applied to the data.
      (default: no)

     -E <expression>
      Specify the expression to apply. Eg. pow(A,6)/(MEAN+MAX)
      Supported operators are +, -, *, /, pow, log,
      abs, cos, exp, sqrt, tan, sin, ceil, floor, rint, (, ),
      MEAN, MAX, MIN, SD, COUNT, SUM, SUMSQUARED, ifelse

     -R <index1,index2-index4,...>
      Specify list of columns to ignore. First and last are valid
      indexes. (default none)

     -V
      Invert matching sense (i.e. only modify specified columns)

Version:
  $Revision: 5543 $
Author:
  Eibe Frank (eibe@cs.waikato.ac.nz), Prados Julien (julien.prados@cui.unige.ch)
See Also:
  - `MathematicalExpression`
  - Serialized Form

## Field Summary

Fields
Modifier and Type
Field
Description
`static final String`
`m_defaultExpression`
The default modification expression

## Constructor Summary

Constructors
Constructor
Description
`MathExpression()`
Constructor

## Method Summary

Modifier and Type
Method
Description
`boolean`
`batchFinished()`
Signify that this batch of input to the filter is finished.
`String`
`expressionTipText()`
Returns the tip text for this property
`Capabilities`
`getCapabilities()`
Returns the Capabilities of this filter.
`String`
`getExpression()`
Get the expression
`String`
`getIgnoreRange()`
Get the current range selection.
`boolean`
`getInvertSelection()`
Get whether the supplied columns are to be select or unselect
`String[]`
`getOptions()`
Gets the current settings of the filter.
`String`
`getRevision()`
Returns the revision string.
`String`
`globalInfo()`
Returns a string describing this filter
`String`
`ignoreRangeTipText()`
Returns the tip text for this property
`boolean`
`input(Instance instance)`
Input an instance for filtering.
`String`
`invertSelectionTipText()`
Returns the tip text for this property
`Enumeration`
`listOptions()`
Returns an enumeration describing the available options.
`static void`
`main(String[] argv)`
Main method for testing this class.
`void`
`setExpression(String expr)`
Set the expression to apply
`void`
`setIgnoreRange(String rangeList)`
Set which attributes are to be ignored
`boolean`
`setInputFormat(Instances instanceInfo)`
Sets the format of the input instances.
`void`
`setInvertSelection(boolean invert)`
Set whether selected columns should be select or unselect.
`void`
`setOptions(String[] options)`
Parses a given list of options.

### Methods inherited from class weka.filters.unsupervised.attribute.PotentialClassIgnorer

`getIgnoreClass, getOutputFormat, ignoreClassTipText, setIgnoreClass`

### Methods inherited from class weka.filters.Filter

`batchFilterFile, filterFile, getCapabilities, isFirstBatchDone, isNewBatch, isOutputFormatDefined, makeCopies, makeCopy, numPendingOutput, output, outputPeek, toString, useFilter, wekaStaticWrapper`

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

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

## Field Details

### m_defaultExpression

public static final String m_defaultExpression
The default modification expression

See Also:
  - Constant Field Values

## Constructor Details

### MathExpression

public MathExpression()
Constructor

## Method Details

### globalInfo

public String globalInfo()
Returns a string describing this filter

Returns:
  a description of the filter suitable for displaying in the explorer/experimenter gui

### getCapabilities

public Capabilities getCapabilities()
Returns the Capabilities of this filter.

Specified by:
  `getCapabilities` in interface `CapabilitiesHandler`
Overrides:
  `getCapabilities` in class `Filter`
Returns:
  the capabilities of this object
See Also:
  - `Capabilities`

### setInputFormat

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

Overrides:
  `setInputFormat` in class `PotentialClassIgnorer`
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 input format can't be set successfully

### input

public boolean input(Instance instance) throws Exception
Input an instance for filtering. Filter requires all training instances be read before producing output.

Overrides:
  `input` in class `Filter`
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 set.
  `Exception` - if the input instance was not of the correct format or if there was a problem with the filtering.

### batchFinished

public boolean batchFinished() throws Exception
Signify that this batch of input to the filter is finished. If the filter requires all instances prior to filtering, output() may now be called to retrieve the filtered instances.

Overrides:
  `batchFinished` in class `Filter`
Returns:
  true if there are instances pending output
Throws:
  `IllegalStateException` - if no input structure has been defined
  `Exception` - if there was a problem finishing the batch.

### setOptions

public void setOptions(String[] options) throws Exception
Parses a given list of options.

Valid options are:

     -unset-class-temporarily
      Unsets the class index temporarily before the filter is
      applied to the data.
      (default: no)

     -E <expression>
      Specify the expression to apply. Eg. pow(A,6)/(MEAN+MAX)
      Supported operators are +, -, *, /, pow, log,
      abs, cos, exp, sqrt, tan, sin, ceil, floor, rint, (, ),
      MEAN, MAX, MIN, SD, COUNT, SUM, SUMSQUARED, ifelse

     -R <index1,index2-index4,...>
      Specify list of columns to ignore. First and last are valid
      indexes. (default none)

     -V
      Invert matching sense (i.e. only modify specified columns)

Specified by:
  `setOptions` in interface `OptionHandler`
Overrides:
  `setOptions` in class `PotentialClassIgnorer`
Parameters:
  `options` - the list of options as an array of strings
Throws:
  `Exception` - if an option is not supported

### getOptions

public String[] getOptions()
Gets the current settings of the filter.

Specified by:
  `getOptions` in interface `OptionHandler`
Overrides:
  `getOptions` in class `PotentialClassIgnorer`
Returns:
  an array of strings suitable for passing to setOptions

### listOptions

public Enumeration listOptions()
Returns an enumeration describing the available options.

Specified by:
  `listOptions` in interface `OptionHandler`
Overrides:
  `listOptions` in class `PotentialClassIgnorer`
Returns:
  an enumeration of all the available options.

### 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

### setExpression

public void setExpression(String expr)
Set the expression to apply

Parameters:
  `expr` - a mathematical expression to apply

### getExpression

public String getExpression()
Get the expression

Returns:
  the expression

### invertSelectionTipText

public String invertSelectionTipText()
Returns the tip text for this property

Returns:
  tip text for this property suitable for displaying in the explorer/experimenter gui

### getInvertSelection

public boolean getInvertSelection()
Get whether the supplied columns are to be select or unselect

Returns:
  true if the supplied columns will be kept

### setInvertSelection

public void setInvertSelection(boolean invert)
Set whether selected columns should be select or unselect. If true the selected columns are modified. If false the selected columns are not modified.

Parameters:
  `invert` - the new invert setting

### ignoreRangeTipText

public String ignoreRangeTipText()
Returns the tip text for this property

Returns:
  tip text for this property suitable for displaying in the explorer/experimenter gui

### getIgnoreRange

public String getIgnoreRange()
Get the current range selection.

Returns:
  a string containing a comma separated list of ranges

### setIgnoreRange

public void setIgnoreRange(String rangeList)
Set which attributes are to be ignored

Parameters:
  `rangeList` - a string representing the list of attributes. Since the string will typically come from a user, attributes are indexed from 1.
  eg: first-3,5,6-last

### getRevision

public String getRevision()
Returns the revision string.

Specified by:
  `getRevision` in interface `RevisionHandler`
Overrides:
  `getRevision` in class `Filter`
Returns:
  the revision

### main

public static void main(String[] argv)
Main method for testing this class.

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