probabilityMachine.vpm
Class VPMKNearestNeighbours

java.lang.Object
  |
  +--weka.classifiers.Classifier
        |
        +--probabilityMachine.VennProbabilityClassifier
              |
              +--probabilityMachine.vpm.VPMKNearestNeighbours
All Implemented Interfaces:
java.lang.Cloneable, OptionHandler, java.io.Serializable, UpdateableClassifier

public class VPMKNearestNeighbours
extends VennProbabilityClassifier
implements UpdateableClassifier, OptionHandler

The VPM K-Nearest Neighbours algorithm. This particular implementation is embedded, meaning that the traditional algorithm has been altered slightly to adapt a method for generating taxonomies of the data using the nearest neighbour information. For more information, see

Self-calibrating Probability Forecasting, Paper Ref?, May 2003, Vladimir Vovk, Glen Shafer, Ilia Nouretdinov

Version:
$Revision: 1.0 $
Author:
David Lindsay (davidl@cs.rhul.ac.uk)
See Also:
Serialized Form

Field Summary
static int CRUDE_NEAREST_NEIGHBOUR
           
static int OTHER
           
static Tag[] TAXONOMY_CHOICE
           
 
Constructor Summary
VPMKNearestNeighbours()
          The amazing VPM K Nearest Neighbours classifier
VPMKNearestNeighbours(int k)
          The amazing VPM K Nearest Neighbours classifier
 
Method Summary
 void buildClassifier(Instances instances)
          Generates the classifier.
 int getDebugEvery()
          Reports whether the VPM is currently in debug mode (if not -1), and specifies how frequently to output message about VPM's progress on data.
 int getKNN()
          Gets the number of neighbours the VPM learner will use.
 java.lang.String[] getOptions()
          Gets the current settings of VPM.
 java.util.Enumeration listOptions()
          Returns an enumeration describing the available options
static void main(java.lang.String[] argv)
          Main method for testing this class.
 void setDebugEvery(int debug)
          Set the VPM to debug its output, outputting its progress as it goes along.
 void setKNN(int k)
          Set the number of neighbours the VPM learner is to use.
 void setOptions(java.lang.String[] options)
          Parses a given list of options.
 java.lang.String toString()
          Returns a description of this classifier.
 void updateClassifier(Instance instance)
          Updates the classifier.
 Matrix vennProbsForInstance(Instance instance)
          Returns the Venn probability matrix for a given test instance.
 
Methods inherited from class probabilityMachine.VennProbabilityClassifier
classifyInstance, computeRowOfVPMMatrix, distributionForInstance, printArray, printArray, returnDistribution, returnUpperAndLowerProbability
 
Methods inherited from class weka.classifiers.Classifier
debugTipText, forName, getDebug, makeCopies, setDebug
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

CRUDE_NEAREST_NEIGHBOUR

public static final int CRUDE_NEAREST_NEIGHBOUR
See Also:
Constant Field Values

OTHER

public static final int OTHER
See Also:
Constant Field Values

TAXONOMY_CHOICE

public static final Tag[] TAXONOMY_CHOICE
Constructor Detail

VPMKNearestNeighbours

public VPMKNearestNeighbours(int k)
The amazing VPM K Nearest Neighbours classifier

Parameters:
k - the number of nearest neighbors to use for prediction

VPMKNearestNeighbours

public VPMKNearestNeighbours()
The amazing VPM K Nearest Neighbours classifier

Method Detail

buildClassifier

public void buildClassifier(Instances instances)
                     throws java.lang.Exception
Generates the classifier.

Specified by:
buildClassifier in class Classifier
Parameters:
instances - set of instances serving as training data
Throws:
java.lang.Exception - if the classifier has not been generated successfully

updateClassifier

public void updateClassifier(Instance instance)
                      throws java.lang.Exception
Updates the classifier.

Specified by:
updateClassifier in interface UpdateableClassifier
Parameters:
instance - the instance to be put into the classifier
Throws:
java.lang.Exception - if the instance could not be included successfully

setKNN

public void setKNN(int k)
Set the number of neighbours the VPM learner is to use.

Parameters:
k - the number of neighbours.

getKNN

public int getKNN()
Gets the number of neighbours the VPM learner will use.

Returns:
the number of neighbours.

setDebugEvery

public void setDebugEvery(int debug)
Set the VPM to debug its output, outputting its progress as it goes along. (Maybe also output alphas?) This is very useful when processing very large data sets, to keep track of its progress (defualt: -1) which specifies no output at all.


getDebugEvery

public int getDebugEvery()
Reports whether the VPM is currently in debug mode (if not -1), and specifies how frequently to output message about VPM's progress on data.

Returns:
how frequently to output debug messages to screen

listOptions

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

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

setOptions

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

-K num
Set the number of nearest neighbors to use in prediction (default 1)

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

getOptions

public java.lang.String[] getOptions()
Gets the current settings of VPM.

Specified by:
getOptions in interface OptionHandler
Overrides:
getOptions in class Classifier
Returns:
an array of strings suitable for passing to setOptions()

vennProbsForInstance

public Matrix vennProbsForInstance(Instance instance)
                            throws java.lang.Exception
Returns the Venn probability matrix for a given test instance.

Specified by:
vennProbsForInstance in class VennProbabilityClassifier
Parameters:
instance - the instance to be classified
Returns:
the Venn probability matrix
Throws:
java.lang.Exception - no training instances

toString

public java.lang.String toString()
Returns a description of this classifier.

Overrides:
toString in class java.lang.Object
Returns:
a description of this classifier as a string.

main

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

Parameters:
argv - should contain command line arguments for evaluation (see Evaluation).


Copyright (c) 2003 David Lindsay, Computer Learning Research Centre, Dept. Computer Science, Royal Holloway, University of London