public class EuclideanDistance extends NormalizableDistance implements java.lang.Cloneable, TechnicalInformationHandler
@misc{missing_id, author = {Wikipedia}, title = {Euclidean distance}, URL = {http://en.wikipedia.org/wiki/Euclidean_distance} }Valid options are:
-D Turns off the normalization of attribute values in distance calculation.
-R <col1,col2-col4,...> Specifies list of columns to used in the calculation of the distance. 'first' and 'last' are valid indices. (default: first-last)
-V Invert matching sense of column indices.
R_MAX, R_MIN, R_WIDTH
Constructor and Description |
---|
EuclideanDistance()
Constructs an Euclidean Distance object, Instances must be still set.
|
EuclideanDistance(Instances data)
Constructs an Euclidean Distance object and automatically initializes the
ranges.
|
Modifier and Type | Method and Description |
---|---|
int |
closestPoint(Instance instance,
Instances allPoints,
int[] pointList)
Returns the index of the closest point to the current instance.
|
double |
distance(Instance first,
Instance second)
Calculates the distance between two instances.
|
double |
distance(Instance first,
Instance second,
PerformanceStats stats)
Calculates the distance (or similarity) between two instances.
|
double |
getMiddle(double[] ranges)
Returns value in the middle of the two parameter values.
|
java.lang.String |
getRevision()
Returns the revision string.
|
TechnicalInformation |
getTechnicalInformation()
Returns an instance of a TechnicalInformation object, containing
detailed information about the technical background of this class,
e.g., paper reference or book this class is based on.
|
java.lang.String |
globalInfo()
Returns a string describing this object.
|
void |
postProcessDistances(double[] distances)
Does post processing of the distances (if necessary) returned by
distance(distance(Instance first, Instance second, double cutOffValue).
|
double |
sqDifference(int index,
double val1,
double val2)
Returns the squared difference of two values of an attribute.
|
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.
|
attributeIndicesTipText, clean, distance, distance, dontNormalizeTipText, getAttributeIndices, getDontNormalize, getInstances, getInvertSelection, getOptions, getRanges, initializeRanges, initializeRanges, initializeRanges, initializeRangesEmpty, inRanges, invertSelectionTipText, listOptions, rangesSet, setAttributeIndices, setDontNormalize, setInstances, setInvertSelection, setOptions, toString, update, updateRanges, updateRanges, updateRanges, updateRangesFirst
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
makeCopy
public EuclideanDistance()
public EuclideanDistance(Instances data)
data
- the instances the distance function should work onpublic java.lang.String globalInfo()
globalInfo
in class NormalizableDistance
public TechnicalInformation getTechnicalInformation()
getTechnicalInformation
in interface TechnicalInformationHandler
public double distance(Instance first, Instance second)
distance
in interface DistanceFunction
distance
in class NormalizableDistance
first
- the first instancesecond
- the second instancepublic double distance(Instance first, Instance second, PerformanceStats stats)
distance
in interface DistanceFunction
distance
in class NormalizableDistance
first
- the first instancesecond
- the second instancestats
- the structure for storing performance statistics.public void postProcessDistances(double[] distances)
postProcessDistances
in interface DistanceFunction
postProcessDistances
in class NormalizableDistance
distances
- the distances to post-processpublic double sqDifference(int index, double val1, double val2)
index
- the attribute indexval1
- the first valueval2
- the second valuepublic double getMiddle(double[] ranges)
ranges
- the ranges to this dimensionpublic int closestPoint(Instance instance, Instances allPoints, int[] pointList) throws java.lang.Exception
instance
- the instance to assign a cluster toallPoints
- all pointspointList
- the list of pointsjava.lang.Exception
- if something goes wrongpublic boolean valueIsSmallerEqual(Instance instance, int dim, double value)
instance
- the instance where the value should be taken ofdim
- the dimension of the valuevalue
- the value to compare withpublic java.lang.String getRevision()
getRevision
in interface RevisionHandler