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)
EuclideanDistance()
- Constructs an Euclidean Distance object.
EuclideanDistance(Instances)
- Constructs an Euclidean Distance object.
EuclideanDistance(Instances, boolean)
- Constructs an Euclidean Distance object.
EuclideanDistance(Instances, double[][])
- Constructs an Euclidean Distance object.
EuclideanDistance(Instances, double[][], boolean)
- Constructs an Euclidean Distance object.
checkInstances()
- Checks the instances.
distance(Instance, Instance)
- Calculates the distance (or similarity) between two instances.
getMiddle(double[])
- Returns value in the middle of the two parameter values.
main(String[])
- Main method for testing this class.
setNumAttributesUsed()
- Computes and sets the number of attributes used.
toString()
- Documents the content of an EuclideanDistance object in a string.
valueIsSmallerEqual(Instance, int, double)
- Returns true if the value of the given dimension is smaller or equal the
value to be compared with.
EuclideanDistance
public EuclideanDistance()
Constructs an Euclidean Distance object.
- Parameters:
data - the instances the distance function should work on
EuclideanDistance
public EuclideanDistance(Instances data)
Constructs an Euclidean Distance object.
- Parameters:
data - the instances the distance function should work on
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
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
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
setNumAttributesUsed
public void setNumAttributesUsed()
Computes and sets the number of attributes used.
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
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
checkInstances
public void checkInstances() throws java.lang.Exception
Checks the instances.
Dataset should only contain nominal or stringumeric attributes.
- Overrides:
- checkInstances in class DistanceFunction
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
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
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