All Packages Class Hierarchy This Package Previous Next Index WEKA's home
java.lang.Object
|
+----weka.core.KDTree
-W
minimal width of a box
-L
maximal instance number in a leaf
-D
Set Normalization. Used when building the tree and selecting the
widest dimension, each dimension is 'normalized' to the universe range.
-U
Set debuglevel.
KDTree()
KDTree(KDTree)
addLooslyInstance(Instance)
buildKDTree(Instances)
buildKDTree(Instances, double[][])
centerInstances(Instances, int[], double)
deleteInstance(Instance)
deleteInstance(int)
findKNearestNeighbour(Instance, int, int[], double[])
getDebugLevel()
getDistanceFunction()
getInstances()
getInstList()
getMaxInstInLeaf()
getMinBoxRelWidth()
getNormalize()
getOptions()
getPrune()
isValid()
listOptions()
main(String[])
numInstances()
setDebugLevel(int)
setDistanceFunction(DistanceFunction)
setMaxInstInLeaf(int)
setMinBoxRelWidth(double)
setNormalize(boolean)
setOptions(String[])
setPrune(boolean)
setValid(boolean)
toString()
updateKDTree(Instance)
R_MIN
public static int R_MIN
Index in ranges for LOW and HIGH and WIDTH
R_MAX
public static int R_MAX
R_WIDTH
public static int R_WIDTH
KDTree
public KDTree()
Default Constructor
KDTree
public KDTree(KDTree tree)
Constructor, copies all options from an existing KDTree.
tree - the KDTree to copy from
addLooslyInstance
public void addLooslyInstance(Instance instance)
Adds one instance to KDTree loosly. It only changes the ranges. The ranges are
important for the distance function.
instance - the new instance
buildKDTree
public void buildKDTree(Instances instances) throws java.lang.Exception
Builds the KDTree.
instances - instances to build the tree of
buildKDTree
public void buildKDTree(Instances instances,
double ranges[][]) throws java.lang.Exception
Builds the KDTree.
It is adviseable to run the replace missing attributes filter on the
passed instances first.
instances - instances to build the tree of
updateKDTree
public void updateKDTree(Instance instance) throws java.lang.Exception
Adds one instance to the KDTree.
instance - the instance to be added
deleteInstance
public void deleteInstance(Instance instance) throws java.lang.Exception
Deletes one instance in the KDTree.
instance - the instance to be deleted
deleteInstance
public boolean deleteInstance(int index) throws java.lang.Exception
Deletes one instance in the KDTree.
index - the index of the instance to be deleted
toString
public java.lang.String toString()
toString
centerInstances
public void centerInstances(Instances centers,
int assignments[],
double pc) throws java.lang.Exception
Assigns instances to centers using KDTree.
centers - the current centers
assignments - the centerindex for each instance
pc - the threshold value for pruning.
p - True if pruning should be used.
findKNearestNeighbour
public int findKNearestNeighbour(Instance target,
int kNN,
int nearestList[],
double distanceList[]) throws java.lang.Exception
Find k nearest neighbours to target. This is the main method.
target - the instance to find nearest neighbour for
maxDist - the distance to the nearest neighbor so far
nearest - the index of the nearest neighbor (second return value)
setValid
public void setValid(boolean valid)
Sets KDTree to be valid for dataset in m_Instances.
flag - if KDtree is valid
isValid
public boolean isValid()
Returns true if valid flag is true.
numInstances
public int numInstances()
Gets number of instances in KDTree.
getInstances
public Instances getInstances()
Gets instances used in the tree.
getInstList
public DynamicArrayOfPosInt getInstList()
Gets instance list used in the tree.
setDistanceFunction
public void setDistanceFunction(DistanceFunction distanceF)
Sets the distance function.
distanceF - the distance function with all options set
getDistanceFunction
public DistanceFunction getDistanceFunction()
Gets the distance function.
setMinBoxRelWidth
public void setMinBoxRelWidth(double i) throws java.lang.Exception
Sets the minimum relative box width.
i - the minimum relative box width
getMinBoxRelWidth
public double getMinBoxRelWidth()
Gets the minimum relative box width.
setMaxInstInLeaf
public void setMaxInstInLeaf(int i) throws java.lang.Exception
Sets the maximum number of instances in a leaf.
i - the maximum number of instances in a leaf
getMaxInstInLeaf
public int getMaxInstInLeaf()
Get the maximum number of instances in a leaf.
setPrune
public void setPrune(boolean p)
Sets the flag for pruning of the blacklisting algorithm.
p - true to use pruning.
getPrune
public boolean getPrune()
Gets the pruning flag.
setNormalize
public void setNormalize(boolean n)
Sets the flag for normalizing the widths of a KDTree Node by the width
of the dimension in the universe.
n - true to use normalizing.
getNormalize
public boolean getNormalize()
Gets the normalize flag.
setDebugLevel
public void setDebugLevel(int d)
Sets the debug level.
debug level = 0, means no output
d - debuglevel
getDebugLevel
public int getDebugLevel()
Gets the debug level.
listOptions
public java.util.Enumeration listOptions()
Returns an enumeration describing the available options.
setOptions
public void setOptions(java.lang.String options[]) throws java.lang.Exception
Parses a given list of options.
options - the list of options as an array of strings
getOptions
public java.lang.String[] getOptions()
Gets the current settings of KDtree.
main
public static void main(java.lang.String args[])
Main method for testing this class
All Packages Class Hierarchy This Package Previous Next Index WEKA's home