Class BallTreeConstructor
java.lang.Object
weka.core.neighboursearch.balltrees.BallTreeConstructor
- All Implemented Interfaces:
Serializable
,OptionHandler
,RevisionHandler
- Direct Known Subclasses:
BottomUpConstructor
,MiddleOutConstructor
,TopDownConstructor
public abstract class BallTreeConstructor
extends Object
implements OptionHandler, Serializable, RevisionHandler
Abstract class for constructing a BallTree .
- Version:
- $Revision: 10203 $
- Author:
- Ashraf M. Kibriya (amk14[at-the-rate]cs[dot]waikato[dot]ac[dot]nz)
- See Also:
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionabstract int[]
addInstance
(BallNode node, Instance inst) Adds an instance to the ball tree.abstract BallNode
Builds the ball tree.Returns the tip text for this property.boolean
Gets whether if a parent ball should completely enclose its two child balls.int
Returns the depth of the built tree.int
Returns the maximum number of instances allowed in a leaf.double
Returns the maximum relative radius of a leaf node.int
Returns the number of leaves in the built tree.int
Returns the number of nodes (internal + leaf) in the built tree.String[]
Gets the current settings.Returns the revision string.Returns an enumeration describing the available options.Returns the tip text for this property.Returns the tip text for this property.void
setContainChildBalls
(boolean containChildBalls) Sets whether if a parent ball should completely enclose its two child balls.void
Sets the distance function to use to build the tree.void
setInstanceList
(int[] instList) Sets the master index array that points to instances in m_Instances, so that only this array is manipulated, and m_Instances is left untouched.void
setInstances
(Instances inst) Sets the instances on which the tree is to be built.void
setMaxInstancesInLeaf
(int num) Sets the maximum number of instances allowed in a leaf.void
setMaxRelativeLeafRadius
(double radius) Sets the maximum relative radius, allowed for a leaf node.void
setOptions
(String[] options) Parses a given list of options.
-
Constructor Details
-
BallTreeConstructor
public BallTreeConstructor()Creates a new instance of BallTreeConstructor.
-
-
Method Details
-
buildTree
Builds the ball tree.- Returns:
- The root node of the tree.
- Throws:
Exception
- If there is problem building the tree.
-
addInstance
Adds an instance to the ball tree.- Parameters:
node
- The root node of the tree.inst
- The instance to add to the tree.- Returns:
- The new master index array after adding the instance.
- Throws:
Exception
- If there is some problem adding the given instance to the tree.
-
maxInstancesInLeafTipText
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the explorer/experimenter gui.
-
getMaxInstancesInLeaf
public int getMaxInstancesInLeaf()Returns the maximum number of instances allowed in a leaf.- Returns:
- The maximum number of instances allowed in a leaf.
-
setMaxInstancesInLeaf
Sets the maximum number of instances allowed in a leaf.- Parameters:
num
- The maximum number of instances allowed in a leaf.- Throws:
Exception
- If the num is < 1.
-
maxRelativeLeafRadiusTipText
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the explorer/experimenter gui.
-
getMaxRelativeLeafRadius
public double getMaxRelativeLeafRadius()Returns the maximum relative radius of a leaf node. It is relative to the radius of the smallest ball enclosing all the data points (that were used to build the tree). This smallest ball would be the same as the root node's ball, if ContainChildBalls property is set to false (default).- Returns:
- The maximum relative radius allowed for a leaf.
-
setMaxRelativeLeafRadius
Sets the maximum relative radius, allowed for a leaf node. The radius is relative to the radius of the smallest ball enclosing all the data points (that were used to build the tree). This smallest ball would be the same as the root node's ball, if ContainChildBalls property is set to false (default).- Parameters:
radius
- The maximum relative radius allowed for a leaf.- Throws:
Exception
- If radius is < 0.0.
-
containChildBallsTipText
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the explorer/experimenter gui.
-
getContainChildBalls
public boolean getContainChildBalls()Gets whether if a parent ball should completely enclose its two child balls.- Returns:
- true if parent ball is to enclose its child balls.
-
setContainChildBalls
public void setContainChildBalls(boolean containChildBalls) Sets whether if a parent ball should completely enclose its two child balls.- Parameters:
containChildBalls
- Should be tree if parent ball is to enclose its child balls.
-
setInstances
Sets the instances on which the tree is to be built.- Parameters:
inst
- The instances on which to build the ball tree.
-
setInstanceList
public void setInstanceList(int[] instList) Sets the master index array that points to instances in m_Instances, so that only this array is manipulated, and m_Instances is left untouched.- Parameters:
instList
- The master index array.
-
setEuclideanDistanceFunction
Sets the distance function to use to build the tree.- Parameters:
func
- The distance function.
-
getNumNodes
public int getNumNodes()Returns the number of nodes (internal + leaf) in the built tree.- Returns:
- The number of nodes in the tree.
-
getNumLeaves
public int getNumLeaves()Returns the number of leaves in the built tree.- Returns:
- The number of leaves in the tree.
-
getMaxDepth
public int getMaxDepth()Returns the depth of the built tree.- Returns:
- The depth of the tree.
-
listOptions
Returns an enumeration describing the available options.- Specified by:
listOptions
in interfaceOptionHandler
- Returns:
- an enumeration of all the available options.
-
setOptions
Parses a given list of options.- Specified by:
setOptions
in interfaceOptionHandler
- Parameters:
options
- the list of options as an array of strings- Throws:
Exception
- if an option is not supported
-
getOptions
Gets the current settings.- Specified by:
getOptions
in interfaceOptionHandler
- Returns:
- an array of strings suitable for passing to setOptions
-
getRevision
Returns the revision string.- Specified by:
getRevision
in interfaceRevisionHandler
- Returns:
- the revision
-