Set debuglevel.
- See Also:
- Serialized Form
Field Summary |
static int |
R_MAX
|
static int |
R_MIN
Index in ranges for LOW and HIGH and WIDTH |
static int |
R_WIDTH
|
Constructor Summary |
KDTree()
Default Constructor |
KDTree(KDTree tree)
Constructor, copies all options from an existing KDTree. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
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.
- Parameters:
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.
- Parameters:
instance
- the new instance
buildKDTree
public void buildKDTree(Instances instances)
throws java.lang.Exception
- Builds the KDTree.
- Parameters:
instances
- instances to build the tree of
- Throws:
java.lang.Exception
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.
- Parameters:
instances
- instances to build the tree of
- Throws:
java.lang.Exception
updateKDTree
public void updateKDTree(Instance instance)
throws java.lang.Exception
- Adds one instance to the KDTree.
- Parameters:
instance
- the instance to be added
- Throws:
java.lang.Exception
deleteInstance
public void deleteInstance(Instance instance)
throws java.lang.Exception
- Deletes one instance in the KDTree.
- Parameters:
instance
- the instance to be deleted
- Throws:
java.lang.Exception
deleteInstance
public boolean deleteInstance(int index)
throws java.lang.Exception
- Deletes one instance in the KDTree.
- Parameters:
index
- the index of the instance to be deleted
- Returns:
- true if instance was deleted
- Throws:
java.lang.Exception
toString
public java.lang.String toString()
- toString
- Returns:
- string representing the tree
centerInstances
public void centerInstances(Instances centers,
int[] assignments,
double pc)
throws java.lang.Exception
- Assigns instances to centers using KDTree.
- Parameters:
centers
- the current centersassignments
- the centerindex for each instancepc
- the threshold value for pruning.
- Throws:
java.lang.Exception
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.
- Parameters:
target
- the instance to find nearest neighbour for
- Throws:
java.lang.Exception
setValid
public void setValid(boolean valid)
- Sets KDTree to be valid for dataset in m_Instances.
isValid
public boolean isValid()
- Returns true if valid flag is true.
- Returns:
- flag if KDtree is valid
numInstances
public int numInstances()
- Gets number of instances in KDTree.
- Returns:
- number of instances
getInstances
public Instances getInstances()
- Gets instances used in the tree.
- Returns:
- model information
getInstList
public DynamicArrayOfPosInt getInstList()
- Gets instance list used in the tree.
- Returns:
- instance list
getDistanceFunctionSpec
protected java.lang.String getDistanceFunctionSpec()
- Gets the distance function specification string,
which contains the class name of distance function
the filter and any options to the filter
- Returns:
- the filter string.
setDistanceFunction
public void setDistanceFunction(DistanceFunction distanceF)
- Sets the distance function.
- Parameters:
distanceF
- the distance function with all options set
getDistanceFunction
public DistanceFunction getDistanceFunction()
- Gets the distance function.
- Returns:
- the distance function
setMinBoxRelWidth
public void setMinBoxRelWidth(double i)
throws java.lang.Exception
- Sets the minimum relative box width.
- Parameters:
i
- the minimum relative box width
- Throws:
java.lang.Exception
getMinBoxRelWidth
public double getMinBoxRelWidth()
- Gets the minimum relative box width.
- Returns:
- the minimum relative box width
setMaxInstInLeaf
public void setMaxInstInLeaf(int i)
throws java.lang.Exception
- Sets the maximum number of instances in a leaf.
- Parameters:
i
- the maximum number of instances in a leaf
- Throws:
java.lang.Exception
getMaxInstInLeaf
public int getMaxInstInLeaf()
- Get the maximum number of instances in a leaf.
- Returns:
- the maximum number of instances in a leaf
setPrune
public void setPrune(boolean p)
- Sets the flag for pruning of the blacklisting algorithm.
- Parameters:
p
- true to use pruning.
getPrune
public boolean getPrune()
- Gets the pruning flag.
- Returns:
- True if pruning
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.
- Parameters:
n
- true to use normalizing.
getNormalize
public boolean getNormalize()
- Gets the normalize flag.
- Returns:
- True if normalizing
setDebugLevel
public void setDebugLevel(int d)
- Sets the debug level.
debug level = 0, means no output
- Parameters:
d
- debuglevel
getDebugLevel
public int getDebugLevel()
- Gets the debug level.
- Returns:
- debug level
listOptions
public java.util.Enumeration listOptions()
- Returns an enumeration describing the available options.
- Specified by:
listOptions
in interface OptionHandler
- Returns:
- an enumeration of all the available options.
setOptions
public void setOptions(java.lang.String[] options)
throws java.lang.Exception
- Parses a given list of options.
- Specified by:
setOptions
in interface OptionHandler
- Parameters:
options
- the list of options as an array of strings
- Throws:
java.lang.Exception
- if an option is not supported
getOptions
public java.lang.String[] getOptions()
- Gets the current settings of KDtree.
- Specified by:
getOptions
in interface OptionHandler
- Returns:
- an array of strings suitable for passing to setOptions
main
public static void main(java.lang.String[] args)
- Main method for testing this class