classifiers.vdm
Class ValueDifferenceMetric

java.lang.Object
  |
  +--coreComponents.DistanceMetric
        |
        +--classifiers.vdm.ValueDifferenceMetric
All Implemented Interfaces:
java.lang.Cloneable, NonExchangeableDistance, java.io.Serializable

public class ValueDifferenceMetric
extends DistanceMetric
implements NonExchangeableDistance, java.lang.Cloneable, java.io.Serializable

Implementation of the Value Difference Metric used in the PEBLS nearest neighbour algorithm detailed in the paper: A Weighted Nearest Neighbor Algorithm for Learning with Symbolic Features 1993, S. Cost and S. Salzberg, John Hopkins University, Baltimore

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

Field Summary
 Instances m_DistanceTrain
          The training set used to generate the VD Matrices
 double m_K
          The type of Minkowski type distance to use (default K=1 Manhatten)
 ValueDifferenceMetric m_TentativeDistanceMetric
           
 classifiers.vdm.ValueDifferenceMetric.VDMatrix[] m_VDMatrix
          The VD Matrices for each attribute
 
Constructor Summary
ValueDifferenceMetric()
          Default constructor
ValueDifferenceMetric(Instances insts)
          More complicated constructor
 
Method Summary
 double calculateTentativeDistance(Instance inst1, Instance inst2)
          Calculate the tentative instance of the classifier.
 boolean checkInstances(Instances insts)
          Check if the instances are valid for the distance metric.
 double computeValueDifference(int attIndex, int attValue1, int attValue2)
           
 double distance(Instance inst1, Instance inst2)
          Calculates the distance between two instances.
static void main(java.lang.String[] args)
           
 void reset(Instances insts)
          This function is useful if we need to reinitialise the distance metric without using the constructor
 boolean setTentativeInstance(Instance inst)
          Sets the instances which we tentatively update the distance metric for.
 java.lang.String toString()
          Creates a debugging string detailing the information about the distance metric
 void updateRanges(Instance inst)
          Update the ranges of the distance metric with a new training instance.
 
Methods inherited from class coreComponents.DistanceMetric
forName
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

m_VDMatrix

public classifiers.vdm.ValueDifferenceMetric.VDMatrix[] m_VDMatrix
The VD Matrices for each attribute


m_DistanceTrain

public Instances m_DistanceTrain
The training set used to generate the VD Matrices


m_K

public double m_K
The type of Minkowski type distance to use (default K=1 Manhatten)


m_TentativeDistanceMetric

public ValueDifferenceMetric m_TentativeDistanceMetric
Constructor Detail

ValueDifferenceMetric

public ValueDifferenceMetric()
Default constructor


ValueDifferenceMetric

public ValueDifferenceMetric(Instances insts)
More complicated constructor

Method Detail

setTentativeInstance

public boolean setTentativeInstance(Instance inst)
Sets the instances which we tentatively update the distance metric for.

Specified by:
setTentativeInstance in interface NonExchangeableDistance

calculateTentativeDistance

public double calculateTentativeDistance(Instance inst1,
                                         Instance inst2)
Calculate the tentative instance of the classifier.

Specified by:
calculateTentativeDistance in interface NonExchangeableDistance

reset

public void reset(Instances insts)
This function is useful if we need to reinitialise the distance metric without using the constructor

Specified by:
reset in class DistanceMetric

updateRanges

public void updateRanges(Instance inst)
Description copied from class: DistanceMetric
Update the ranges of the distance metric with a new training instance.

Specified by:
updateRanges in class DistanceMetric
Parameters:
inst - the instance to update with
Returns:
nothing

computeValueDifference

public double computeValueDifference(int attIndex,
                                     int attValue1,
                                     int attValue2)

distance

public double distance(Instance inst1,
                       Instance inst2)
Description copied from class: DistanceMetric
Calculates the distance between two instances.

Specified by:
distance in class DistanceMetric
Parameters:
inst1 - the first instance
inst2 - the second instance
Returns:
the distance between the two instances

toString

public java.lang.String toString()
Description copied from class: DistanceMetric
Creates a debugging string detailing the information about the distance metric

Specified by:
toString in class DistanceMetric
Returns:
a debugging string

checkInstances

public boolean checkInstances(Instances insts)
Description copied from class: DistanceMetric
Check if the instances are valid for the distance metric.

Specified by:
checkInstances in class DistanceMetric
Parameters:
insts - the training instances to be checked
Returns:
true if the instances are valid, false otherwise

main

public static void main(java.lang.String[] args)


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