Package weka.classifiers.trees.ht
Class HNode
- java.lang.Object
-
- weka.classifiers.trees.ht.HNode
-
- All Implemented Interfaces:
java.io.Serializable
public abstract class HNode extends java.lang.Object implements java.io.SerializableAbstract 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 Summary
Fields Modifier and Type Field Description java.util.Map<java.lang.String,WeightMass>m_classDistributionClass distribution at this node
-
Constructor Summary
Constructors Constructor Description HNode()Construct a new HNodeHNode(java.util.Map<java.lang.String,WeightMass> classDistrib)Construct a new HNode with the supplied class distribution
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description booleanclassDistributionIsPure()Returns true if the class distribution is puredouble[]getDistribution(Instance inst, Attribute classAtt)Return a class probability distribution computed from the frequency counts at this nodevoidgraphTree(java.lang.StringBuffer text)intinstallNodeNums(int nodeNum)booleanisLeaf()Returns true if this is a leafLeafNodeleafForInstance(Instance inst, SplitNode parent, java.lang.String parentBranch)Return the leaf that the supplied instance ends up atintnumEntriesInClassDistribution()The size of the class distributionjava.lang.StringtoString(boolean printLeaf)Print a textual description of the treedoubletotalWeight()Return the total weight of instances seen at this nodevoidupdateDistribution(Instance inst)Update the class frequency distribution with the supplied instanceabstract voidupdateNode(Instance inst)Update the node with the supplied instance
-
-
-
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 forclassAtt- 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 forparent- the parent nodeparentBranch- 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
-
-