类 SubsetByExpression

所有已实现的接口:
Serializable, CapabilitiesHandler, OptionHandler, RevisionHandler

public class SubsetByExpression extends SimpleBatchFilter
Filters instances according to a user-specified expression.

Grammar:

boolexpr_list ::= boolexpr_list boolexpr_part | boolexpr_part;

boolexpr_part ::= boolexpr:e {: parser.setResult(e); :} ;

boolexpr ::= BOOLEAN
| true
| false
| expr < expr
| expr <= expr
| expr > expr
| expr >= expr
| expr = expr
| ( boolexpr )
| not boolexpr
| boolexpr and boolexpr
| boolexpr or boolexpr
| ATTRIBUTE is STRING
;

expr ::= NUMBER
| ATTRIBUTE
| ( expr )
| opexpr
| funcexpr
;

opexpr ::= expr + expr
| expr - expr
| expr * expr
| expr / expr
;

funcexpr ::= abs ( expr )
| sqrt ( expr )
| log ( expr )
| exp ( expr )
| sin ( expr )
| cos ( expr )
| tan ( expr )
| rint ( expr )
| floor ( expr )
| pow ( expr for base , expr for exponent )
| ceil ( expr )
;

Notes:
- NUMBER
any integer or floating point number
(but not in scientific notation!)
- STRING
any string surrounded by single quotes;
the string may not contain a single quote though.
- ATTRIBUTE
the following placeholders are recognized for
attribute values:
- CLASS for the class value in case a class attribute is set.
- ATTxyz with xyz a number from 1 to # of attributes in the
dataset, representing the value of indexed attribute.

Examples:
- extracting only mammals and birds from the 'zoo' UCI dataset:
(CLASS is 'mammal') or (CLASS is 'bird')
- extracting only animals with at least 2 legs from the 'zoo' UCI dataset:
(ATT14 >= 2)
- extracting only instances with non-missing 'wage-increase-second-year'
from the 'labor' UCI dataset:
not ismissing(ATT3)

Valid options are:

 -E <expr>
  The expression to use for filtering
  (default: true).
 -F
  Apply the filter to instances that arrive after the first
  (training) batch. The default is to not apply the filter (i.e.
  always return the instance)
版本:
$Revision: 9804 $
作者:
fracpete (fracpete at waikato dot ac dot nz)
另请参阅:
  • 构造器详细资料

    • SubsetByExpression

      public SubsetByExpression()
  • 方法详细资料

    • globalInfo

      public String globalInfo()
      Returns a string describing this filter.
      指定者:
      globalInfo 在类中 SimpleFilter
      返回:
      a description of the filter suitable for displaying in the explorer/experimenter gui
    • input

      public boolean input(Instance instance) throws Exception
      Input an instance for filtering. Filter requires all training instances be read before producing output (calling the method batchFinished() makes the data available). If this instance is part of a new batch, m_NewBatch is set to false.
      覆盖:
      input 在类中 SimpleBatchFilter
      参数:
      instance - the input instance
      返回:
      true if the filtered instance may now be collected with output().
      抛出:
      IllegalStateException - if no input structure has been defined
      Exception - if something goes wrong
      另请参阅:
    • listOptions

      public Enumeration listOptions()
      Returns an enumeration describing the available options.
      指定者:
      listOptions 在接口中 OptionHandler
      覆盖:
      listOptions 在类中 SimpleFilter
      返回:
      an enumeration of all the available options.
    • setOptions

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

      Valid options are:

       -E <expr>
        The expression to use for filtering
        (default: true).
       -F
        Apply the filter to instances that arrive after the first
        (training) batch. The default is to not apply the filter (i.e.
        always return the instance)
      指定者:
      setOptions 在接口中 OptionHandler
      覆盖:
      setOptions 在类中 SimpleFilter
      参数:
      options - the list of options as an array of strings
      抛出:
      Exception - if an option is not supported
      另请参阅:
      • SimpleFilter.reset()
    • getOptions

      public String[] getOptions()
      Gets the current settings of the filter.
      指定者:
      getOptions 在接口中 OptionHandler
      覆盖:
      getOptions 在类中 SimpleFilter
      返回:
      an array of strings suitable for passing to setOptions
    • getCapabilities

      public Capabilities getCapabilities()
      Returns the Capabilities of this filter.
      指定者:
      getCapabilities 在接口中 CapabilitiesHandler
      覆盖:
      getCapabilities 在类中 Filter
      返回:
      the capabilities of this object
      另请参阅:
    • setExpression

      public void setExpression(String value)
      Sets the expression used for filtering.
      参数:
      value - the expression
    • getExpression

      public String getExpression()
      Returns the expression used for filtering.
      返回:
      the expression
    • expressionTipText

      public String expressionTipText()
      Returns the tip text for this property.
      返回:
      tip text for this property suitable for displaying in the explorer/experimenter gui
    • setFilterAfterFirstBatch

      public void setFilterAfterFirstBatch(boolean b)
      Set whether to apply the filter to instances that arrive once the first (training) batch has been seen. The default is to not apply the filter and just return each instance input. This is so that, when used in the FilteredClassifier, a test instance does not get "consumed" by the filter and a prediction is always generated.
      参数:
      b - true if the filter should be applied to instances that arrive after the first (training) batch has been processed.
    • getFilterAfterFirstBatch

      public boolean getFilterAfterFirstBatch()
      Get whether to apply the filter to instances that arrive once the first (training) batch has been seen. The default is to not apply the filter and just return each instance input. This is so that, when used in the FilteredClassifier, a test instance does not get "consumed" by the filter and a prediction is always generated.
      返回:
      true if the filter should be applied to instances that arrive after the first (training) batch has been processed.
    • filterAfterFirstBatchTipText

      public String filterAfterFirstBatchTipText()
      Returns the tip text for this property.
      返回:
      tip text for this property suitable for displaying in the explorer/experimenter gui
    • getRevision

      public String getRevision()
      Returns the revision string.
      指定者:
      getRevision 在接口中 RevisionHandler
      覆盖:
      getRevision 在类中 Filter
      返回:
      the revision
    • main

      public static void main(String[] args)
      Main method for running this filter.
      参数:
      args - arguments for the filter: use -h for help