All Packages  Class Hierarchy  This Package  Previous  Next  Index  WEKA's home

Class weka.classifiers.bayes.BayesNet

java.lang.Object
    |
    +----weka.classifiers.Classifier
            |
            +----weka.classifiers.DistributionClassifier
                    |
                    +----weka.classifiers.bayes.BayesNet

public class BayesNet
extends DistributionClassifier
implements OptionHandler, WeightedInstancesHandler
Base class for a Bayes Network classifier. Provides datastructures (network structure, conditional probability distributions, etc.) and facilities common to Bayes Network learning algorithms like K2 and B. Works with nominal variables and no missing values only.

Version:
$Revision: 1.7 $
Author:
Remco Bouckaert (rrb@xm.co.nz)

Variable Index

 o m_Instances
The dataset header for the purposes of printing out a semi-intelligible model
 o TAGS_SCORE_TYPE
 

Constructor Index

 o BayesNet()
 

Method Index

 o alphaTipText()
 
 o buildClassifier(Instances)
Generates the classifier.
 o buildStructure()
buildStructure determines the network structure/graph of the network.
 o countsForInstance(Instance)
Calculates the counts for Dirichlet distribution for the class membership probabilities for the given test instance.
 o distributionForInstance(Instance)
Calculates the class membership probabilities for the given test instance.
 o estimateCPTs()
estimateCPTs estimates the conditional probability tables for the Bayes Net using the network structure.
 o getAlpha()
Method declaration
 o getInitAsNaiveBayes()
Method declaration
 o getMaxNrOfParents()
Method declaration
 o getOptions()
Gets the current settings of the classifier.
 o getScoreType()
Method declaration
 o getUseADTree()
Method declaration
 o initAsNaiveBayesTipText()
 
 o initStructure()
Init structure initializes the structure to an empty graph or a Naive Bayes graph (depending on the -N flag).
 o listOptions()
Returns an enumeration describing the available options
 o logScore(int)
logScore returns the log of the quality of a network (e.g.
 o main(String[])
Main method for testing this class.
 o maxNrOfParentsTipText()
 
 o scoreTypeTipText()
 
 o setAlpha(double)
Method declaration
 o setInitAsNaiveBayes(boolean)
Method declaration
 o setMaxNrOfParents(int)
Method declaration
 o setOptions(String[])
Parses a given list of options.
 o setScoreType(SelectedTag)
Method declaration
 o setUseADTree(boolean)
Method declaration
 o toString()
Returns a description of the classifier.
 o updateClassifier(Instance)
Updates the classifier with the given instance.
 o useADTreeTipText()
 

Field Detail

 o m_Instances
public Instances m_Instances
          The dataset header for the purposes of printing out a semi-intelligible model
 o TAGS_SCORE_TYPE
public static final Tag[] TAGS_SCORE_TYPE

Constructor Detail

 o BayesNet
public BayesNet()

Method Detail

 o buildClassifier
public void buildClassifier(Instances instances) throws java.lang.Exception
          Generates the classifier.
Parameters:
instances - set of instances serving as training data
Throws:
java.lang.Exception - if the classifier has not been generated successfully
Overrides:
buildClassifier in class Classifier
 o initStructure
public void initStructure() throws java.lang.Exception
          Init structure initializes the structure to an empty graph or a Naive Bayes graph (depending on the -N flag).
 o buildStructure
public void buildStructure() throws java.lang.Exception
          buildStructure determines the network structure/graph of the network. The default behavior is creating a network where all nodes have the first node as its parent (i.e., a BayesNet that behaves like a naive Bayes classifier). This method can be overridden by derived classes to restrict the class of network structures that are acceptable.
 o estimateCPTs
public void estimateCPTs() throws java.lang.Exception
          estimateCPTs estimates the conditional probability tables for the Bayes Net using the network structure.
 o updateClassifier
public void updateClassifier(Instance instance) throws java.lang.Exception
          Updates the classifier with the given instance.
Parameters:
instance - the new training instance to include in the model
Throws:
java.lang.Exception - if the instance could not be incorporated in the model.
 o distributionForInstance
public double[] distributionForInstance(Instance instance) throws java.lang.Exception
          Calculates the class membership probabilities for the given test instance.
Parameters:
instance - the instance to be classified
Returns:
predicted class probability distribution
Throws:
java.lang.Exception - if there is a problem generating the prediction
Overrides:
distributionForInstance in class DistributionClassifier
 o countsForInstance
public double[] countsForInstance(Instance instance) throws java.lang.Exception
          Calculates the counts for Dirichlet distribution for the class membership probabilities for the given test instance.
Parameters:
instance - the instance to be classified
Returns:
counts for Dirichlet distribution for class probability
Throws:
java.lang.Exception - if there is a problem generating the prediction
 o listOptions
public java.util.Enumeration listOptions()
          Returns an enumeration describing the available options
Returns:
an enumeration of all the available options
 o setOptions
public void setOptions(java.lang.String options[]) throws java.lang.Exception
          Parses a given list of options. Valid options are:

Parameters:
options - the list of options as an array of strings
Throws:
java.lang.Exception - if an option is not supported
 o setScoreType
public void setScoreType(SelectedTag newScoreType)
          Method declaration
Parameters:
scoreType -
 o getScoreType
public SelectedTag getScoreType()
          Method declaration
Returns:
 o setAlpha
public void setAlpha(double fAlpha)
          Method declaration
Parameters:
fAlpha -
 o getAlpha
public double getAlpha()
          Method declaration
Returns:
 o setInitAsNaiveBayes
public void setInitAsNaiveBayes(boolean bInitAsNaiveBayes)
          Method declaration
Parameters:
bInitAsNaiveBayes -
 o getInitAsNaiveBayes
public boolean getInitAsNaiveBayes()
          Method declaration
Returns:
 o setUseADTree
public void setUseADTree(boolean bUseADTree)
          Method declaration
Parameters:
bUseADTree -
 o getUseADTree
public boolean getUseADTree()
          Method declaration
Returns:
 o setMaxNrOfParents
public void setMaxNrOfParents(int nMaxNrOfParents)
          Method declaration
Parameters:
nMaxNrOfParents -
 o getMaxNrOfParents
public int getMaxNrOfParents()
          Method declaration
Returns:
 o getOptions
public java.lang.String[] getOptions()
          Gets the current settings of the classifier.
Returns:
an array of strings suitable for passing to setOptions
 o logScore
public double logScore(int nType)
          logScore returns the log of the quality of a network (e.g. the posterior probability of the network, or the MDL value).
Parameters:
nType - score type (Bayes, MDL, etc) to calculate score with
Returns:
log score.
 o toString
public java.lang.String toString()
          Returns a description of the classifier.
Returns:
a description of the classifier as a string.
Overrides:
toString in class java.lang.Object
 o scoreTypeTipText
public java.lang.String scoreTypeTipText()
Returns:
a string to describe the ScoreType option.
 o alphaTipText
public java.lang.String alphaTipText()
Returns:
a string to describe the Alpha option.
 o initAsNaiveBayesTipText
public java.lang.String initAsNaiveBayesTipText()
Returns:
a string to describe the InitAsNaiveBayes option.
 o useADTreeTipText
public java.lang.String useADTreeTipText()
Returns:
a string to describe the UseADTreeoption.
 o maxNrOfParentsTipText
public java.lang.String maxNrOfParentsTipText()
Returns:
a string to describe the MaxNrOfParentsoption.
 o main
public static void main(java.lang.String argv[])
          Main method for testing this class.
Parameters:
argv - the options

All Packages  Class Hierarchy  This Package  Previous  Next  Index  WEKA's home