Class HNode

  • All Implemented Interfaces:
    java.io.Serializable
    Direct Known Subclasses:
    LeafNode, SplitNode

    public abstract class HNode
    extends java.lang.Object
    implements java.io.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:
    Serialized Form
    • Field Detail

      • m_classDistribution

        public java.util.Map<java.lang.String,​WeightMass> m_classDistribution
        Class distribution at this node
    • Constructor Detail

      • HNode

        public HNode()
        Construct a new HNode
      • HNode

        public HNode​(java.util.Map<java.lang.String,​WeightMass> classDistrib)
        Construct a new HNode with the supplied class distribution
        Parameters:
        classDistrib -
    • Method Detail

      • 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 java.lang.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:
        java.lang.Exception - if a problem occurs
      • installNodeNums

        public int installNodeNums​(int nodeNum)
      • graphTree

        public void graphTree​(java.lang.StringBuffer text)
      • toString

        public java.lang.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,
                                        java.lang.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 java.lang.Exception
        Update the node with the supplied instance
        Parameters:
        inst - the instance to update with
        Throws:
        java.lang.Exception - if a problem occurs