Package weka.filters.unsupervised.attribute

# Class KernelFilter

java.lang.Object
weka.filters.Filter
weka.filters.SimpleFilter
weka.filters.SimpleBatchFilter
weka.filters.unsupervised.attribute.KernelFilter

All Implemented Interfaces:
  `Serializable`, `CapabilitiesHandler`, `CapabilitiesIgnorer`, `CommandlineRunnable`, `OptionHandler`, `RevisionHandler`, `TechnicalInformationHandler`, `UnsupervisedFilter`

public class KernelFilter extends SimpleBatchFilter implements UnsupervisedFilter, TechnicalInformationHandler
Converts the given set of data into a kernel matrix. The class value remains unchanged as long as the chosen preprocessing filter does not change it.
By default, the data is preprocessed with the Center filter, but the user can choose any filter. (NB: one must be careful that the filter does not alter the class attribute unintentionally.) With weka.filters.AllFilter the preprocessing gets disabled.
For more information regarding preprocessing the data, see:
K.P. Bennett, M.J. Embrechts: An Optimization Perspective on Kernel Partial Least Squares Regression. In: Advances in Learning Theory: Methods, Models and Applications, 227-249, 2003.

BibTeX:

     @inproceedings{Bennett2003,
        author = {K.P. Bennett and M.J. Embrechts},
        booktitle = {Advances in Learning Theory: Methods, Models and Applications},
        editor = {J. Suykens et al.},
        pages = {227-249},
        publisher = {IOS Press, Amsterdam, The Netherlands},
        series = {NATO Science Series, Series III: Computer and System Sciences},
        title = {An Optimization Perspective on Kernel Partial Least Squares Regression},
        volume = {190},
        year = {2003}
     }

Valid options are:

     -output-debug-info
      Turns on output of debugging information.

     -no-checks
      Turns off all checks - use with caution!
      Turning them off assumes that data is purely numeric, doesn't
      contain any missing values, and has a nominal class. Turning them
      off also means that no header information will be stored if the
      machine is linear. Finally, it also assumes that no instance has
      a weight equal to 0.
      (default: checks on)

     -F <filename>
      The file to initialize the filter with (optional).

     -C <num>
      The class index for the file to initialize with,
      First and last are valid (optional, default: last).

     -K <classname and parameters>
      The Kernel to use.
      (default: weka.classifiers.functions.supportVector.PolyKernel)

     -kernel-factor
      Defines a factor for the kernel.
       - RBFKernel: a factor for gamma
        Standardize: 1/(2*N)
        Normalize..: 6/N
      Available parameters are:
       N for # of instances, A for # of attributes
      (default: 1)

     -P <classname and parameters>
      The Filter used for preprocessing (use weka.filters.AllFilter
      to disable preprocessing).
      (default: weka.filters.unsupervised.attribute.Center)

     Options specific to kernel weka.classifiers.functions.supportVector.PolyKernel:

     -D
      Enables debugging output (if available) to be printed.
      (default: off)

     -no-checks
      Turns off all checks - use with caution!
      (default: checks on)

     -C <num>
      The size of the cache (a prime number), 0 for full cache and
      -1 to turn it off.
      (default: 250007)

     -E <num>
      The Exponent to use.
      (default: 1.0)

     -L
      Use lower-order terms.
      (default: no)

     Options specific to preprocessing filter weka.filters.unsupervised.attribute.Center:

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

Version:
  $Revision: 14271 $
Author:
  Jonathan Miles (jdm18@cs.waikato.ac.nz), FracPete (fracpete at waikato dot ac dot nz)
See Also:
  - Serialized Form

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `KernelFilter()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `String`
  `checksTurnedOffTipText()`
  Returns the tip text for this property
  `Capabilities`
  `getCapabilities()`
  Returns the Capabilities of this filter.
  `boolean`
  `getChecksTurnedOff()`
  Returns whether the checks are turned off or not.
  `File`
  `getInitFile()`
  Gets the file to initialize the filter with, can be null.
  `String`
  `getInitFileClassIndex()`
  Gets the class index of the file to initialize the filter with.
  `Kernel`
  `getKernel()`
  Gets the kernel to use.
  `String`
  `getKernelFactorExpression()`
  Gets the expression for the kernel.
  `String[]`
  `getOptions()`
  Gets the current settings of the filter.
  `Filter`
  `getPreprocessing()`
  Gets the filter used for preprocessing
  `String`
  `getRevision()`
  Returns the revision string.
  `TechnicalInformation`
  `getTechnicalInformation()`
  Returns an instance of a TechnicalInformation object, containing detailed information about the technical background of this class, e.g., paper reference or book this class is based on.
  `String`
  `globalInfo()`
  Returns a string describing this filter.
  `String`
  `initFileClassIndexTipText()`
  Returns the tip text for this property
  `String`
  `initFileTipText()`
  Returns the tip text for this property
  `void`
  `initFilter(Instances instances)`
  initializes the filter with the given dataset, i.e., the kernel gets built.
  `String`
  `kernelFactorExpressionTipText()`
  Returns the tip text for this property
  `String`
  `kernelTipText()`
  Returns the tip text for this property
  `Enumeration<Option>`
  `listOptions()`
  Returns an enumeration describing the available options.
  `static void`
  `main(String[] args)`
  runs the filter with the given arguments
  `String`
  `preprocessingTipText()`
  Returns the tip text for this property
  `void`
  `setChecksTurnedOff(boolean value)`
  Disables or enables the checks (which could be time-consuming).
  `void`
  `setInitFile(File value)`
  Sets the file to initialize the filter with, can be null.
  `void`
  `setInitFileClassIndex(String value)`
  Sets class index of the file to initialize the filter with.
  `void`
  `setKernel(Kernel value)`
  Sets the kernel to use.
  `void`
  `setKernelFactorExpression(String value)`
  Sets the expression for the kernel.
  `void`
  `setOptions(String[] options)`
  Parses a given list of options.
  `void`
  `setPreprocessing(Filter value)`
  Sets the filter to use for preprocessing (use the AllFilter for no preprocessing)

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

  `allowAccessToFullInputFormat, batchFinished, input, input`

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

  `setInputFormat`

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

  `batchFilterFile, debugTipText, doNotCheckCapabilitiesTipText, filterFile, getCapabilities, getCopyOfInputFormat, getDebug, getDoNotCheckCapabilities, getOutputFormat, isFirstBatchDone, isNewBatch, isOutputFormatDefined, makeCopies, makeCopy, mayRemoveInstanceAfterFirstBatchDone, numPendingOutput, output, outputPeek, postExecution, preExecution, run, runFilter, setDebug, setDoNotCheckCapabilities, toString, useFilter, wekaStaticWrapper`

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

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

- ## Constructor Details

  - ### KernelFilter

    public KernelFilter()

- ## Method Details

  - ### globalInfo

    public String globalInfo()
    Returns a string describing this filter.
    Specified by:
      `globalInfo` in class `SimpleFilter`
    Returns:
      a description of the filter suitable for displaying in the explorer/experimenter gui

  - ### getTechnicalInformation

    public TechnicalInformation getTechnicalInformation()
    Returns an instance of a TechnicalInformation object, containing detailed information about the technical background of this class, e.g., paper reference or book this class is based on.
    Specified by:
      `getTechnicalInformation` in interface `TechnicalInformationHandler`
    Returns:
      the technical information about this class

  - ### listOptions

    public Enumeration<Option> listOptions()
    Returns an enumeration describing the available options.
    Specified by:
      `listOptions` in interface `OptionHandler`
    Overrides:
      `listOptions` in class `Filter`
    Returns:
      an enumeration of all the available options.

  - ### getOptions

    public String[] getOptions()
    Gets the current settings of the filter.
    Specified by:
      `getOptions` in interface `OptionHandler`
    Overrides:
      `getOptions` in class `Filter`
    Returns:
      an array of strings suitable for passing to setOptions

  - ### setOptions

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

    Valid options are:

         -D
          Turns on output of debugging information.

         -no-checks
          Turns off all checks - use with caution!
          Turning them off assumes that data is purely numeric, doesn't
          contain any missing values, and has a nominal class. Turning them
          off also means that no header information will be stored if the
          machine is linear. Finally, it also assumes that no instance has
          a weight equal to 0.
          (default: checks on)

         -F <filename>
          The file to initialize the filter with (optional).

         -C <num>
          The class index for the file to initialize with,
          First and last are valid (optional, default: last).

         -K <classname and parameters>
          The Kernel to use.
          (default: weka.classifiers.functions.supportVector.PolyKernel)

         -kernel-factor
          Defines a factor for the kernel.
           - RBFKernel: a factor for gamma
            Standardize: 1/(2*N)
            Normalize..: 6/N
          Available parameters are:
           N for # of instances, A for # of attributes
          (default: 1)

         -P <classname and parameters>
          The Filter used for preprocessing (use weka.filters.AllFilter
          to disable preprocessing).
          (default: weka.filters.unsupervised.attribute.Center)

         Options specific to kernel weka.classifiers.functions.supportVector.PolyKernel:

         -D
          Enables debugging output (if available) to be printed.
          (default: off)

         -no-checks
          Turns off all checks - use with caution!
          (default: checks on)

         -C <num>
          The size of the cache (a prime number), 0 for full cache and
          -1 to turn it off.
          (default: 250007)

         -E <num>
          The Exponent to use.
          (default: 1.0)

         -L
          Use lower-order terms.
          (default: no)

         Options specific to preprocessing filter weka.filters.unsupervised.attribute.Center:

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

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

  - ### initFileTipText

    public String initFileTipText()
    Returns the tip text for this property
    Returns:
      tip text for this property suitable for displaying in the explorer/experimenter gui

  - ### getInitFile

    public File getInitFile()
    Gets the file to initialize the filter with, can be null.
    Returns:
      the file

  - ### setInitFile

    public void setInitFile(File value)
    Sets the file to initialize the filter with, can be null.
    Parameters:
      `value` - the file

  - ### initFileClassIndexTipText

    public String initFileClassIndexTipText()
    Returns the tip text for this property
    Returns:
      tip text for this property suitable for displaying in the explorer/experimenter gui

  - ### getInitFileClassIndex

    public String getInitFileClassIndex()
    Gets the class index of the file to initialize the filter with.
    Returns:
      the class index

  - ### setInitFileClassIndex

    public void setInitFileClassIndex(String value)
    Sets class index of the file to initialize the filter with.
    Parameters:
      `value` - the class index

  - ### kernelTipText

    public String kernelTipText()
    Returns the tip text for this property
    Returns:
      tip text for this property suitable for displaying in the explorer/experimenter gui

  - ### getKernel

    public Kernel getKernel()
    Gets the kernel to use.
    Returns:
      the kernel

  - ### setKernel

    public void setKernel(Kernel value)
    Sets the kernel to use.
    Parameters:
      `value` - the kernel

  - ### setChecksTurnedOff

    public void setChecksTurnedOff(boolean value)
    Disables or enables the checks (which could be time-consuming). Use with caution!
    Parameters:
      `value` - if true turns off all checks

  - ### getChecksTurnedOff

    public boolean getChecksTurnedOff()
    Returns whether the checks are turned off or not.
    Returns:
      true if the checks are turned off

  - ### checksTurnedOffTipText

    public String checksTurnedOffTipText()
    Returns the tip text for this property
    Returns:
      tip text for this property suitable for displaying in the explorer/experimenter gui

  - ### kernelFactorExpressionTipText

    public String kernelFactorExpressionTipText()
    Returns the tip text for this property
    Returns:
      tip text for this property suitable for displaying in the explorer/experimenter gui

  - ### getKernelFactorExpression

    public String getKernelFactorExpression()
    Gets the expression for the kernel.
    Returns:
      the expression

  - ### setKernelFactorExpression

    public void setKernelFactorExpression(String value)
    Sets the expression for the kernel.
    Parameters:
      `value` - the file

  - ### preprocessingTipText

    public String preprocessingTipText()
    Returns the tip text for this property
    Returns:
      tip text for this property suitable for displaying in the explorer/experimenter gui

  - ### setPreprocessing

    public void setPreprocessing(Filter value)
    Sets the filter to use for preprocessing (use the AllFilter for no preprocessing)
    Parameters:
      `value` - the preprocessing filter

  - ### getPreprocessing

    public Filter getPreprocessing()
    Gets the filter used for preprocessing
    Returns:
      the current preprocessing filter.

  - ### initFilter

    public void initFilter(Instances instances) throws Exception
    initializes the filter with the given dataset, i.e., the kernel gets built. Needs to be called before the first call of Filter.useFilter or batchFinished(), if not the -F option (or setInitFile(File) is used).
    Parameters:
      `instances` - the data to initialize with
    Throws:
      `Exception` - if building of kernel fails

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

  - ### 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[] args)
    runs the filter with the given arguments
    Parameters:
      `args` - the commandline arguments