All Packages  Class Hierarchy  This Package  Previous  Next  Index  WEKA's home

Class weka.core.EuclideanDistance

java.lang.Object
    |
    +----weka.core.DistanceFunction
            |
            +----weka.core.EuclideanDistance

public class EuclideanDistance
extends DistanceFunction
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.

Version:
$Revision: 1.3 $
Author:
Gabi Schmidberger (gabi@cs.waikato.ac.nz)

Constructor Index

 o EuclideanDistance()
Constructs an Euclidean Distance object.
 o EuclideanDistance(Instances)
Constructs an Euclidean Distance object.
 o EuclideanDistance(Instances, boolean)
Constructs an Euclidean Distance object.
 o EuclideanDistance(Instances, double[][])
Constructs an Euclidean Distance object.
 o EuclideanDistance(Instances, double[][], boolean)
Constructs an Euclidean Distance object.

Method Index

 o checkInstances()
Checks the instances.
 o distance(Instance, Instance)
Calculates the distance (or similarity) between two instances.
 o getMiddle(double[])
Returns value in the middle of the two parameter values.
 o main(String[])
Main method for testing this class.
 o setNumAttributesUsed()
Computes and sets the number of attributes used.
 o toString()
Documents the content of an EuclideanDistance object in a string.
 o valueIsSmallerEqual(Instance, int, double)
Returns true if the value of the given dimension is smaller or equal the value to be compared with.

Constructor Detail

 o EuclideanDistance
public EuclideanDistance()
          Constructs an Euclidean Distance object.
Parameters:
data - the instances the distance function should work on
 o EuclideanDistance
public EuclideanDistance(Instances data)
          Constructs an Euclidean Distance object.
Parameters:
data - the instances the distance function should work on
 o EuclideanDistance
public EuclideanDistance(Instances data,
                         boolean normalize)
          Constructs an Euclidean Distance object.
Parameters:
data - the instances the distance function should work on
normalize - if true normalization is done
 o EuclideanDistance
public EuclideanDistance(Instances data,
                         double ranges[][])
          Constructs an Euclidean Distance object. Ranges are already given.
Parameters:
data - the instances the distance function should work on
ranges - the min and max values of the attribute values
 o EuclideanDistance
public EuclideanDistance(Instances data,
                         double ranges[][],
                         boolean normalize)
          Constructs an Euclidean Distance object. Ranges are already given.
Parameters:
data - the instances the distance function should work on
ranges - the min and max values of the attribute values
normalize - if true normalization is done

Method Detail

 o setNumAttributesUsed
public void setNumAttributesUsed()
          Computes and sets the number of attributes used.
 o distance
public double distance(Instance first,
                       Instance second) throws java.lang.Exception
          Calculates the distance (or similarity) between two instances.
Parameters:
first - the first instance
second - the second instance
Returns:
the distance between the two given instances,
Overrides:
distance in class DistanceFunction
 o getMiddle
public double getMiddle(double ranges[])
          Returns value in the middle of the two parameter values.
Parameters:
range - the ranges to this dimension
Returns:
the middle value
Overrides:
getMiddle in class DistanceFunction
 o checkInstances
public void checkInstances() throws java.lang.Exception
          Checks the instances. Dataset should only contain nominal or stringumeric attributes.
Overrides:
checkInstances in class DistanceFunction
 o valueIsSmallerEqual
public boolean valueIsSmallerEqual(Instance instance,
                                   int dim,
                                   double value)
          Returns true if the value of the given dimension is smaller or equal the value to be compared with.
Parameters:
instance - the instance where the value should be taken of
dim - the dimension of the value
the - value to compare with
Returns:
true is value of instance is smaller or equal value
Overrides:
valueIsSmallerEqual in class DistanceFunction
 o toString
public java.lang.String toString()
          Documents the content of an EuclideanDistance object in a string.
Returns:
the converted string
Overrides:
toString in class DistanceFunction
 o main
public static void main(java.lang.String args[])
          Main method for testing this class.

All Packages  Class Hierarchy  This Package  Previous  Next  Index  WEKA's home