Class HNode

java.lang.Object
weka.classifiers.trees.ht.HNode
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
LeafNode, SplitNode

public abstract class HNode extends Object implements Serializable
Abstract base class for nodes in a Hoeffding tree
Author:
Richard Kirkby (rkirkby@cs.waikato.ac.nz), Mark Hall (mhall{[at]}pentaho{[dot]}com)
See Also:
  • Field Details

    • m_classDistribution

      public Map<String,WeightMass> m_classDistribution
      Class distribution at this node
  • Constructor Details

    • HNode

      public HNode()
      Construct a new HNode
    • HNode

      public HNode(Map<String,WeightMass> classDistrib)
      Construct a new HNode with the supplied class distribution
      Parameters:
      classDistrib -
  • Method Details

    • isLeaf

      public boolean isLeaf()
      Returns true if this is a leaf
      Returns:
    • numEntriesInClassDistribution

      public int numEntriesInClassDistribution()
      The size of the class distribution
      Returns:
      the number of entries in the class distribution
    • classDistributionIsPure

      public boolean classDistributionIsPure()
      Returns true if the class distribution is pure
      Returns:
      true if the class distribution is pure
    • updateDistribution

      public void updateDistribution(Instance inst)
      Update the class frequency distribution with the supplied instance
      Parameters:
      inst - the instance to update with
    • getDistribution

      public double[] getDistribution(Instance inst, Attribute classAtt) throws Exception
      Return a class probability distribution computed from the frequency counts at this node
      Parameters:
      inst - the instance to get a prediction for
      classAtt - the class attribute
      Returns:
      a class probability distribution
      Throws:
      Exception - if a problem occurs
    • installNodeNums

      public int installNodeNums(int nodeNum)
    • graphTree

      public void graphTree(StringBuffer text)
    • toString

      public String toString(boolean printLeaf)
      Print a textual description of the tree
      Parameters:
      printLeaf - true if leaf models (NB, NB adaptive) should be output
      Returns:
      a textual description of the tree
    • totalWeight

      public double totalWeight()
      Return the total weight of instances seen at this node
      Returns:
      the total weight of instances seen at this node
    • leafForInstance

      public LeafNode leafForInstance(Instance inst, SplitNode parent, String parentBranch)
      Return the leaf that the supplied instance ends up at
      Parameters:
      inst - the instance to find the leaf for
      parent - the parent node
      parentBranch - the parent branch
      Returns:
      the leaf that the supplied instance ends up at
    • updateNode

      public abstract void updateNode(Instance inst) throws Exception
      Update the node with the supplied instance
      Parameters:
      inst - the instance to update with
      Throws:
      Exception - if a problem occurs