|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectweka.core.DistanceFunction
weka.core.EuclideanDistance
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.
Field Summary | |
protected boolean |
m_Normalize
True if normalization should be done |
protected double |
m_NumAttributesUsed
The number of attributes the contribute to a prediction |
Fields inherited from class weka.core.DistanceFunction |
m_Model, m_Ranges, R_MAX, R_MIN, R_WIDTH |
Constructor Summary | |
EuclideanDistance()
Constructs an Euclidean Distance object. |
|
EuclideanDistance(Instances data)
Constructs an Euclidean Distance object. |
|
EuclideanDistance(Instances data,
boolean normalize)
Constructs an Euclidean Distance object. |
|
EuclideanDistance(Instances data,
double[][] ranges)
Constructs an Euclidean Distance object. |
|
EuclideanDistance(Instances data,
double[][] ranges,
boolean normalize)
Constructs an Euclidean Distance object. |
Method Summary | |
void |
checkInstances()
Checks the instances. |
double |
distance(Instance first,
Instance second)
Calculates the distance (or similarity) between two instances. |
double |
getMiddle(double[] ranges)
Returns value in the middle of the two parameter values. |
static void |
main(java.lang.String[] args)
Main method for testing this class. |
void |
setNumAttributesUsed()
Computes and sets the number of attributes used. |
java.lang.String |
toString()
Documents the content of an EuclideanDistance object in a string. |
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. |
Methods inherited from class weka.core.DistanceFunction |
closestPoint, updateRanges |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
protected boolean m_Normalize
protected double m_NumAttributesUsed
Constructor Detail |
public EuclideanDistance()
public EuclideanDistance(Instances data)
data
- the instances the distance function should work onpublic EuclideanDistance(Instances data, boolean normalize)
data
- the instances the distance function should work onnormalize
- if true normalization is donepublic EuclideanDistance(Instances data, double[][] ranges)
data
- the instances the distance function should work onranges
- the min and max values of the attribute valuespublic EuclideanDistance(Instances data, double[][] ranges, boolean normalize)
data
- the instances the distance function should work onranges
- the min and max values of the attribute valuesnormalize
- if true normalization is doneMethod Detail |
public void setNumAttributesUsed()
public double distance(Instance first, Instance second) throws java.lang.Exception
distance
in class DistanceFunction
first
- the first instancesecond
- the second instance
java.lang.Exception
public double getMiddle(double[] ranges)
getMiddle
in class DistanceFunction
public void checkInstances() throws java.lang.Exception
checkInstances
in class DistanceFunction
java.lang.Exception
public boolean valueIsSmallerEqual(Instance instance, int dim, double value)
valueIsSmallerEqual
in class DistanceFunction
instance
- the instance where the value should be taken ofdim
- the dimension of the value
public java.lang.String toString()
toString
in class DistanceFunction
public static void main(java.lang.String[] args)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |