All Packages Class Hierarchy This Package Previous Next Index WEKA's home
Class weka.core.DistanceFunction
java.lang.Object
|
+----weka.core.DistanceFunction
- public abstract class DistanceFunction
- extends java.lang.Object
- implements java.io.Serializable
Abstract class to implement a distance function.
- Version:
- $Revision: 1.2 $
- Author:
- Gabi Schmidberger (gabi@cs.waikato.ac.nz)
m_Ranges- the range of the attributes
DistanceFunction()
- Constructs a distance function object.
DistanceFunction(Instances)
- Constructs a distance function object.
DistanceFunction(Instances, double[][])
- Constructs a distance function object.
checkInstances()
- Checks the instances if compatibel with the distance function.
closestPoint(Instance, Instances, int[])
- Returns the index of the closest point to the current instance.
distance(Instance, Instance)
- Calculates the distance (or similarity) between two instances.
getMiddle(double[])
- Returns value in the middle of the two parameter values.
toString()
- Converts a DistanceFunction object to a string
updateRanges(Instance)
- Update the ranges if a new instance comes.
valueIsSmallerEqual(Instance, int, double)
- Returns true if the value of the given dimension is smaller or equal the
value to be compared with.
m_Ranges
public double[][] m_Ranges
the range of the attributes
DistanceFunction
public DistanceFunction()
Constructs a distance function object.
DistanceFunction
public DistanceFunction(Instances data)
Constructs a distance function object.
- Parameters:
data - the instances the distance function should work on.
DistanceFunction
public DistanceFunction(Instances data,
double ranges[][])
Constructs a distance function 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
distance
public abstract 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,
getMiddle
public abstract 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
checkInstances
public abstract void checkInstances() throws java.lang.Exception
Checks the instances if compatibel with the distance function.
- Parameters:
range - the ranges to this dimension
- Returns:
- the middle value
valueIsSmallerEqual
public abstract 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
closestPoint
public int closestPoint(Instance instance,
Instances allPoints,
int pointList[]) throws java.lang.Exception
Returns the index of the closest point to the current instance.
Index is index in Instances object that is the second parameter.
- Parameters:
instance - the instance to assign a cluster to
centers - all centers
centList - the centers to cluster the instance to
- Returns:
- a cluster index
updateRanges
public void updateRanges(Instance instance)
Update the ranges if a new instance comes.
- Parameters:
instance - the new instance
toString
public java.lang.String toString()
Converts a DistanceFunction object to a string
- Returns:
- a string describing a distance function
- Overrides:
- toString in class java.lang.Object
All Packages Class Hierarchy This Package Previous Next Index WEKA's home