coreComponents
Class EuclideanDistanceMetric

java.lang.Object
  |
  +--coreComponents.DistanceMetric
        |
        +--coreComponents.EuclideanDistanceMetric
All Implemented Interfaces:
java.lang.Cloneable, java.io.Serializable

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

Implementing Euclidean distance (or similarity) function. One object defines not one distance but the data model in which the distances between objects of that data model can be computed. Attention: For efficiency reasons the use of consistency checks (like are the data models of the two instances exactly the same), is low. This has been updated for my own personal (davidl) needs!

Version:
$Revision: 1.3 $
Author:
Gabi Schmidberger (gabi@cs.waikato.ac.nz), David Lindsay (davidl@cs.rhul.ac.uk)
See Also:
Serialized Form

Field Summary
 Instances m_Model
           
 
Constructor Summary
EuclideanDistanceMetric()
          Constructs an Euclidean Distance object.
EuclideanDistanceMetric(Instances data)
          Constructs an Euclidean Distance object.
 
Method Summary
 void checkInstances()
          Checks the instances.
 boolean checkInstances(Instances instances)
          Check if the instances are valid for the distance metric.
 double distance(Instance first, Instance second)
          Calculates the distance (or similarity) between two instances.
static void main(java.lang.String[] args)
          Main method for testing this class.
 void reset(Instances instances)
          This function is useful if we need to reinitialise the distance metric without using the constructor
 java.lang.String toString()
          Documents the content of an EuclideanDistance object in a string.
 void updateRanges(Instance inst1)
          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_Model

public Instances m_Model
Constructor Detail

EuclideanDistanceMetric

public EuclideanDistanceMetric()
Constructs an Euclidean Distance object.


EuclideanDistanceMetric

public EuclideanDistanceMetric(Instances data)
Constructs an Euclidean Distance object.

Parameters:
data - the instances the distance function should work on
Method Detail

checkInstances

public boolean checkInstances(Instances instances)
Check if the instances are valid for the distance metric.

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

reset

public void reset(Instances instances)
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 inst1)
Update the ranges of the distance metric with a new training instance.

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

distance

public double distance(Instance first,
                       Instance second)
Calculates the distance (or similarity) between two instances.

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

checkInstances

public void checkInstances()
                    throws java.lang.Exception
Checks the instances. Dataset should only contain nominal or stringumeric attributes.

java.lang.Exception

toString

public java.lang.String toString()
Documents the content of an EuclideanDistance object in a string.

Specified by:
toString in class DistanceMetric
Returns:
the converted string

main

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



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