Class CheckKernel

java.lang.Object
weka.core.Check
weka.core.CheckScheme
weka.classifiers.functions.supportVector.CheckKernel
All Implemented Interfaces:
OptionHandler, RevisionHandler

public class CheckKernel extends CheckScheme
Class for examining the capabilities and finding problems with kernels. If you implement an kernels using the WEKA.libraries, you should run the checks on it to ensure robustness and correct operation. Passing all the tests of this object does not mean bugs in the kernels don't exist, but this will help find some common ones.

Typical usage:

java weka.classifiers.functions.supportVector.CheckKernel -W kernel_name -- kernel_options

CheckKernel reports on the following:

  • Kernel abilities
    • Possible command line options to the kernels
    • Whether the kernels can predict nominal, numeric, string, date or relational class attributes.
    • Whether the kernels can handle numeric predictor attributes
    • Whether the kernels can handle nominal predictor attributes
    • Whether the kernels can handle string predictor attributes
    • Whether the kernels can handle date predictor attributes
    • Whether the kernels can handle relational predictor attributes
    • Whether the kernels can handle multi-instance data
    • Whether the kernels can handle missing predictor values
    • Whether the kernels can handle missing class values
    • Whether a nominal kernels only handles 2 class problems
    • Whether the kernels can handle instance weights
  • Correct functioning
    • Correct initialisation during buildKernel (i.e. no result changes when buildKernel called repeatedly)
    • Whether the kernels alters the data passed to it (number of instances, instance order, instance weights, etc)
  • Degenerate cases
    • building kernels with zero training instances
    • all but one predictor attribute values missing
    • all predictor attribute values missing
    • all but one class values missing
    • all class values missing
Running CheckKernel with the debug option set will output the training and test datasets for any failed tests.

The weka.classifiers.AbstractKernelTest uses this class to test all the kernels. Any changes here, have to be checked in that abstract test class, too.

Valid options are:

 -D
  Turn on debugging output.
 
 -S
  Silent mode - prints nothing to stdout.
 
 -N <num>
  The number of instances in the datasets (default 20).
 
 -nominal <num>
  The number of nominal attributes (default 2).
 
 -nominal-values <num>
  The number of values for nominal attributes (default 1).
 
 -numeric <num>
  The number of numeric attributes (default 1).
 
 -string <num>
  The number of string attributes (default 1).
 
 -date <num>
  The number of date attributes (default 1).
 
 -relational <num>
  The number of relational attributes (default 1).
 
 -num-instances-relational <num>
  The number of instances in relational/bag attributes (default 10).
 
 -words <comma-separated-list>
  The words to use in string attributes.
 
 -word-separators <chars>
  The word separators to use in string attributes.
 
 -W
  Full name of the kernel analysed.
  eg: weka.classifiers.functions.supportVector.RBFKernel
  (default weka.classifiers.functions.supportVector.RBFKernel)
 
 Options specific to kernel weka.classifiers.functions.supportVector.RBFKernel:
 
 -D
  Enables debugging output (if available) to be printed.
  (default: off)
 
 -C <num>
  The size of the cache (a prime number), 0 for full cache and 
  -1 to turn it off.
  (default: 250007)
 
 -G <num>
  The Gamma parameter.
  (default: 0.01)
 
Options after -- are passed to the designated kernel.

Version:
$Revision: 14516 $
Author:
Len Trigg (trigg@cs.waikato.ac.nz), FracPete (fracpete at waikato dot ac dot nz)
See Also:
  • Constructor Details

    • CheckKernel

      public CheckKernel()
  • Method Details

    • listOptions

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

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

       -D
        Turn on debugging output.
       
       -S
        Silent mode - prints nothing to stdout.
       
       -N <num>
        The number of instances in the datasets (default 20).
       
       -nominal <num>
        The number of nominal attributes (default 2).
       
       -nominal-values <num>
        The number of values for nominal attributes (default 1).
       
       -numeric <num>
        The number of numeric attributes (default 1).
       
       -string <num>
        The number of string attributes (default 1).
       
       -date <num>
        The number of date attributes (default 1).
       
       -relational <num>
        The number of relational attributes (default 1).
       
       -num-instances-relational <num>
        The number of instances in relational/bag attributes (default 10).
       
       -words <comma-separated-list>
        The words to use in string attributes.
       
       -word-separators <chars>
        The word separators to use in string attributes.
       
       -W
        Full name of the kernel analysed.
        eg: weka.classifiers.functions.supportVector.RBFKernel
        (default weka.classifiers.functions.supportVector.RBFKernel)
       
       Options specific to kernel weka.classifiers.functions.supportVector.RBFKernel:
       
       -D
        Enables debugging output (if available) to be printed.
        (default: off)
       
       -C <num>
        The size of the cache (a prime number), 0 for full cache and 
        -1 to turn it off.
        (default: 250007)
       
       -G <num>
        The Gamma parameter.
        (default: 0.01)
       
      Specified by:
      setOptions in interface OptionHandler
      Overrides:
      setOptions in class CheckScheme
      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 CheckKernel.
      Specified by:
      getOptions in interface OptionHandler
      Overrides:
      getOptions in class CheckScheme
      Returns:
      an array of strings suitable for passing to setOptions
    • doTests

      public void doTests()
      Begin the tests, reporting results to System.out
      Specified by:
      doTests in class CheckScheme
    • setKernel

      public void setKernel(Kernel value)
      Set the lernel to test.
      Parameters:
      value - the kernel to use.
    • getKernel

      public Kernel getKernel()
      Get the kernel being tested
      Returns:
      the kernel being tested
    • getRevision

      public String getRevision()
      Returns the revision string.
      Returns:
      the revision
    • main

      public static void main(String[] args)
      Test method for this class
      Parameters:
      args - the commandline parameters