cbr.similarity
Class EuclideanDistanceMetric

java.lang.Object
  extended by cbr.similarity.EuclideanDistanceMetric
All Implemented Interfaces:
SimilarityMetric

public class EuclideanDistanceMetric
extends Object
implements SimilarityMetric

Provides implementation for a Euclidean Distance Metric. The following formula is used:
Similarity = 1 - (|value1 - value2| / MAX_VALUE)
Which produces a normalised, inverted similarity value between two values.


Constructor Summary
EuclideanDistanceMetric(double max)
          Creates a Euclidean Distance Metric given a value for the maximum distance between two values.
 
Method Summary
 double compare(Feature f1, Feature f2)
          Derives the normalised, inverted 1-dimensional Euclidean distance between two numerical feature values
 double getMax()
          Returns the maximum value, used in the equation for this metric.
 void setMax(double max)
          Specify the maximum difference between two numerical values
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EuclideanDistanceMetric

public EuclideanDistanceMetric(double max)
Creates a Euclidean Distance Metric given a value for the maximum distance between two values.

Parameters:
max - the maximum value between two feature values
Method Detail

getMax

public double getMax()
Returns the maximum value, used in the equation for this metric.

Returns:
the maximum value

setMax

public void setMax(double max)
Specify the maximum difference between two numerical values

Parameters:
max - the maximum value

compare

public double compare(Feature f1,
                      Feature f2)
Derives the normalised, inverted 1-dimensional Euclidean distance between two numerical feature values

Specified by:
compare in interface SimilarityMetric
Parameters:
f1 - a case feature
f2 - another case feature
Returns:
1.0 is exactly similar, 0.0 is entirely dissimilar