coreComponents
Class DistanceMetric

java.lang.Object
  |
  +--coreComponents.DistanceMetric
Direct Known Subclasses:
EuclideanDistanceMetric, USMDistanceFunction, ValueDifferenceMetric

public abstract class DistanceMetric
extends java.lang.Object

Abstract class for implementing specialised distance measures.

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

Constructor Summary
DistanceMetric()
           
 
Method Summary
abstract  boolean checkInstances(Instances instances)
          Check if the instances are valid for the distance metric.
abstract  double distance(Instance inst1, Instance inst2)
          Calculates the distance between two instances.
static DistanceMetric forName(java.lang.String distanceMetricName, java.lang.String[] options)
          Creates a new instance of a distance metric given it's class name and (optional) arguments to pass to it's setOptions method.
abstract  void reset(Instances instances)
          This function is useful if we need to reinitialise the distance metric without using the constructor
abstract  java.lang.String toString()
          Creates a debugging string detailing the information about the distance metric
abstract  void updateRanges(Instance inst1)
          Update the ranges of the distance metric with a new training instance.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DistanceMetric

public DistanceMetric()
Method Detail

reset

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


distance

public abstract double distance(Instance inst1,
                                Instance inst2)
Calculates the distance between two instances.

Parameters:
inst1 - the first instance
inst2 - the second instance
Returns:
the distance between the two instances

toString

public abstract java.lang.String toString()
Creates a debugging string detailing the information about the distance metric

Overrides:
toString in class java.lang.Object
Returns:
a debugging string

updateRanges

public abstract void updateRanges(Instance inst1)
Update the ranges of the distance metric with a new training instance.

Parameters:
inst1 - the instance to update with
Returns:
nothing

checkInstances

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

Parameters:
instances - the training instances to be checked
Returns:
true if the instances are valid, false otherwise

forName

public static DistanceMetric forName(java.lang.String distanceMetricName,
                                     java.lang.String[] options)
                              throws java.lang.Exception
Creates a new instance of a distance metric given it's class name and (optional) arguments to pass to it's setOptions method. If the distance metric implements OptionHandler and the options parameter is non-null, the distance metric will have it's options set.

Parameters:
distanceMetricName - the fully qualified class name of the
options - an array of options suitable for passing to setOptions. May be null.
Returns:
the newly created distance metric, ready for use.
Throws:
java.lang.Exception - if the distance metric name is invalid, or the options supplied are not acceptable to the distance metric


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