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)

Variable Index

 o m_Ranges
the range of the attributes

Constructor Index

 o DistanceFunction()
Constructs a distance function object.
 o DistanceFunction(Instances)
Constructs a distance function object.
 o DistanceFunction(Instances, double[][])
Constructs a distance function object.

Method Index

 o checkInstances()
Checks the instances if compatibel with the distance function.
 o closestPoint(Instance, Instances, int[])
Returns the index of the closest point to the current instance.
 o distance(Instance, Instance)
Calculates the distance (or similarity) between two instances.
 o getMiddle(double[])
Returns value in the middle of the two parameter values.
 o toString()
Converts a DistanceFunction object to a string
 o updateRanges(Instance)
Update the ranges if a new instance comes.
 o valueIsSmallerEqual(Instance, int, double)
Returns true if the value of the given dimension is smaller or equal the value to be compared with.

Field Detail

 o m_Ranges
public double[][] m_Ranges
          the range of the attributes

Constructor Detail

 o DistanceFunction
public DistanceFunction()
          Constructs a distance function object.
 o DistanceFunction
public DistanceFunction(Instances data)
          Constructs a distance function object.
Parameters:
data - the instances the distance function should work on.
 o 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

Method Detail

 o 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,
 o 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
 o 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
 o 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
 o 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
 o updateRanges
public void updateRanges(Instance instance)
          Update the ranges if a new instance comes.
Parameters:
instance - the new instance
 o 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