public class EuclideanDistance extends NormalizableDistance implements Cloneable
@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.
m_ActiveIndices, m_Data, m_DontNormalize, m_Ranges, m_Validated, R_MAX, R_MIN, R_WIDTH| Constructor and Description |
|---|
EuclideanDistance()
Constructs an Euclidean Distance object, Instances must be still set.
|
EuclideanDistance(weka.core.Instances data)
Constructs an Euclidean Distance object and automatically initializes the
ranges.
|
| Modifier and Type | Method and Description |
|---|---|
int |
closestPoint(weka.core.Instance instance,
weka.core.Instances allPoints,
int[] pointList)
Returns the index of the closest point to the current instance.
|
double |
distance(weka.core.Instance first,
weka.core.Instance second)
Calculates the distance between two instances.
|
double |
getMiddle(double[] ranges)
Returns value in the middle of the two parameter values.
|
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.
|
protected double |
updateDistance(double currDist,
double diff)
Updates the current distance calculated so far with the new difference
between two attributes.
|
boolean |
valueIsSmallerEqual(weka.core.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, difference, distance, dontNormalizeTipText, getAttributeIndices, getDontNormalize, getInstances, getInvertSelection, getRanges, initialize, initializeAttributeIndices, initializeRanges, initializeRanges, initializeRanges, initializeRangesEmpty, inRanges, invalidate, invertSelectionTipText, isMissingValue, norm, rangesSet, setAttributeIndices, setDontNormalize, setInstances, setInvertSelection, toString, update, updateRanges, updateRanges, updateRanges, updateRangesFirst, validatepublic EuclideanDistance()
public EuclideanDistance(weka.core.Instances data)
data - the instances the distance function should work onpublic String globalInfo()
globalInfo in class NormalizableDistancepublic double distance(weka.core.Instance first,
weka.core.Instance second)
distance in interface DistanceFunctiondistance in class NormalizableDistancefirst - the first instancesecond - the second instanceprotected double updateDistance(double currDist,
double diff)
updateDistance in class NormalizableDistancecurrDist - the current distance calculated so fardiff - the difference between two new attributesNormalizableDistance.difference(int, double, double)public void postProcessDistances(double[] distances)
postProcessDistances in interface DistanceFunctionpostProcessDistances in class NormalizableDistancedistances - 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(weka.core.Instance instance,
weka.core.Instances allPoints,
int[] pointList)
throws Exception
instance - the instance to assign a cluster toallPoints - all pointspointList - the list of pointsException - if something goes wrongpublic boolean valueIsSmallerEqual(weka.core.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 withCopyright © 2014 University of Waikato, Hamilton, NZ. All Rights Reserved.