Package weka.core.neighboursearch.balltrees

# 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:
  - Serialized Form

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `BallTreeConstructor()`
  Creates a new instance of BallTreeConstructor.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `abstract int[]`
  `addInstance(BallNode node, Instance inst)`
  Adds an instance to the ball tree.
  `abstract BallNode`
  `buildTree()`
  Builds the ball tree.
  `String`
  `containChildBallsTipText()`
  Returns the tip text for this property.
  `boolean`
  `getContainChildBalls()`
  Gets whether if a parent ball should completely enclose its two child balls.
  `int`
  `getMaxDepth()`
  Returns the depth of the built tree.
  `int`
  `getMaxInstancesInLeaf()`
  Returns the maximum number of instances allowed in a leaf.
  `double`
  `getMaxRelativeLeafRadius()`
  Returns the maximum relative radius of a leaf node.
  `int`
  `getNumLeaves()`
  Returns the number of leaves in the built tree.
  `int`
  `getNumNodes()`
  Returns the number of nodes (internal + leaf) in the built tree.
  `String[]`
  `getOptions()`
  Gets the current settings.
  `String`
  `getRevision()`
  Returns the revision string.
  `Enumeration<Option>`
  `listOptions()`
  Returns an enumeration describing the available options.
  `String`
  `maxInstancesInLeafTipText()`
  Returns the tip text for this property.
  `String`
  `maxRelativeLeafRadiusTipText()`
  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`
  `setEuclideanDistanceFunction(EuclideanDistance func)`
  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.

  ### Methods inherited from class java.lang.Object

  `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### BallTreeConstructor

    public BallTreeConstructor()
    Creates a new instance of BallTreeConstructor.

- ## Method Details

  - ### buildTree

    public abstract BallNode buildTree() throws Exception
    Builds the ball tree.
    Returns:
      The root node of the tree.
    Throws:
      `Exception` - If there is problem building the tree.

  - ### addInstance

    public abstract int[] addInstance(BallNode node, Instance inst) throws Exception
    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

    public String 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

    public void setMaxInstancesInLeaf(int num) throws Exception
    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

    public String 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

    public void setMaxRelativeLeafRadius(double radius) throws Exception
    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

    public String 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

    public void setInstances(Instances inst)
    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

    public void setEuclideanDistanceFunction(EuclideanDistance func)
    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

    public Enumeration<Option> 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(String[] options) throws 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:
      `Exception` - if an option is not supported

  - ### getOptions

    public String[] getOptions()
    Gets the current settings.
    Specified by:
      `getOptions` in interface `OptionHandler`
    Returns:
      an array of strings suitable for passing to setOptions

  - ### getRevision

    public String getRevision()
    Returns the revision string.
    Specified by:
      `getRevision` in interface `RevisionHandler`
    Returns:
      the revision