public class BayesNet extends Classifier implements OptionHandler, WeightedInstancesHandler, Drawable, AdditionalMeasureProducer
-D Do not use ADTree data structure
-B <BIF file> BIF file to compare with
-Q weka.classifiers.bayes.net.search.SearchAlgorithm Search algorithm
-E weka.classifiers.bayes.net.estimate.SimpleEstimator Estimator algorithm
Modifier and Type | Field and Description |
---|---|
Estimator[][] |
m_Distributions
The attribute estimators containing CPTs.
|
Instances |
m_Instances
The dataset header for the purposes of printing out a semi-intelligible
model
|
BayesNet, Newick, NOT_DRAWABLE, TREE
Constructor and Description |
---|
BayesNet() |
Modifier and Type | Method and Description |
---|---|
java.lang.String |
BIFFileTipText() |
void |
buildClassifier(Instances instances)
Generates the classifier.
|
void |
buildStructure()
buildStructure determines the network structure/graph of the network.
|
double[] |
countsForInstance(Instance instance)
Calculates the counts for Dirichlet distribution for the
class membership probabilities for the given test instance.
|
double[] |
distributionForInstance(Instance instance)
Calculates the class membership probabilities for the given test
instance.
|
java.util.Enumeration |
enumerateMeasures()
Returns an enumeration of the measure names.
|
void |
estimateCPTs()
estimateCPTs estimates the conditional probability tables for the Bayes
Net using the network structure.
|
java.lang.String |
estimatorTipText()
This will return a string describing the BayesNetEstimator.
|
ADNode |
getADTree()
get ADTree strucrture containing efficient representation of counts.
|
java.lang.String |
getBIFFile()
Get name of network in BIF file to compare with
|
java.lang.String |
getBIFHeader() |
Capabilities |
getCapabilities()
Returns default capabilities of the classifier.
|
int |
getCardinality(int iNode)
get number of values a node can take
|
Estimator[][] |
getDistributions()
Get full set of estimators.
|
BayesNetEstimator |
getEstimator()
Get the BayesNetEstimator used for calculating the CPTs
|
double |
getMeasure(java.lang.String measureName)
Returns the value of the named measure
|
java.lang.String |
getName()
get name of the Bayes network
|
java.lang.String |
getNodeName(int iNode)
get name of a node in the Bayes network
|
java.lang.String |
getNodeValue(int iNode,
int iValue)
get name of a particular value of a node
|
int |
getNrOfNodes()
get number of nodes in the Bayes network
|
int |
getNrOfParents(int iNode)
get number of parents of a node in the network structure
|
java.lang.String[] |
getOptions()
Gets the current settings of the classifier.
|
int |
getParent(int iNode,
int iParent)
get node index of a parent of a node in the network structure
|
int |
getParentCardinality(int iNode)
get number of values the collection of parents of a node can take
|
ParentSet |
getParentSet(int iNode)
get the parent set of a node
|
ParentSet[] |
getParentSets()
Get full set of parent sets.
|
double |
getProbability(int iNode,
int iParent,
int iValue)
get particular probability of the conditional probability distribtion
of a node given its parents.
|
java.lang.String |
getRevision()
Returns the revision string.
|
SearchAlgorithm |
getSearchAlgorithm()
Get the SearchAlgorithm used as the search algorithm
|
boolean |
getUseADTree()
Method declaration
|
java.lang.String |
globalInfo()
This will return a string describing the classifier.
|
java.lang.String |
graph()
Returns a BayesNet graph in XMLBIF ver 0.3 format.
|
int |
graphType()
Returns the type of graph this classifier
represents.
|
void |
initCPTs()
initializes the conditional probabilities
|
void |
initStructure()
Init structure initializes the structure to an empty graph or a Naive Bayes
graph (depending on the -N flag).
|
java.util.Enumeration |
listOptions()
Returns an enumeration describing the available options
|
static void |
main(java.lang.String[] argv)
Main method for testing this class.
|
double |
measureAICScore() |
double |
measureBayesScore() |
double |
measureBDeuScore() |
double |
measureDivergence() |
double |
measureEntropyScore() |
double |
measureExtraArcs() |
double |
measureMDLScore() |
double |
measureMissingArcs() |
double |
measureReversedArcs() |
static java.lang.String[] |
partitionOptions(java.lang.String[] options)
Returns the secondary set of options (if any) contained in
the supplied options array.
|
java.lang.String |
searchAlgorithmTipText() |
void |
setBIFFile(java.lang.String sBIFFile)
Set name of network in BIF file to compare with
|
void |
setEstimator(BayesNetEstimator newBayesNetEstimator)
Set the Estimator Algorithm used in calculating the CPTs
|
void |
setOptions(java.lang.String[] options)
Parses a given list of options.
|
void |
setSearchAlgorithm(SearchAlgorithm newSearchAlgorithm)
Set the SearchAlgorithm used in searching for network structures.
|
void |
setUseADTree(boolean bUseADTree)
Set whether ADTree structure is used or not
|
java.lang.String |
toString()
Returns a description of the classifier.
|
java.lang.String |
toXMLBIF03()
Returns a description of the classifier in XML BIF 0.3 format.
|
void |
updateClassifier(Instance instance)
Updates the classifier with the given instance.
|
java.lang.String |
useADTreeTipText() |
classifyInstance, debugTipText, forName, getDebug, makeCopies, makeCopy, setDebug
public Estimator[][] m_Distributions
public Instances m_Instances
public Capabilities getCapabilities()
getCapabilities
in interface CapabilitiesHandler
getCapabilities
in class Classifier
Capabilities
public void buildClassifier(Instances instances) throws java.lang.Exception
buildClassifier
in class Classifier
instances
- set of instances serving as training datajava.lang.Exception
- if the classifier has not been generated
successfullypublic void initStructure() throws java.lang.Exception
java.lang.Exception
- in case of an errorpublic void buildStructure() throws java.lang.Exception
java.lang.Exception
- in case of an errorpublic void estimateCPTs() throws java.lang.Exception
java.lang.Exception
- in case of an errorpublic void initCPTs() throws java.lang.Exception
java.lang.Exception
- in case of an errorpublic void updateClassifier(Instance instance) throws java.lang.Exception
instance
- the new training instance to include in the modeljava.lang.Exception
- if the instance could not be incorporated in
the model.public double[] distributionForInstance(Instance instance) throws java.lang.Exception
distributionForInstance
in class Classifier
instance
- the instance to be classifiedjava.lang.Exception
- if there is a problem generating the predictionpublic double[] countsForInstance(Instance instance) throws java.lang.Exception
instance
- the instance to be classifiedjava.lang.Exception
- if there is a problem generating the predictionpublic java.util.Enumeration listOptions()
listOptions
in interface OptionHandler
listOptions
in class Classifier
public void setOptions(java.lang.String[] options) throws java.lang.Exception
Valid options are:
-D Do not use ADTree data structure
-B <BIF file> BIF file to compare with
-Q weka.classifiers.bayes.net.search.SearchAlgorithm Search algorithm
-E weka.classifiers.bayes.net.estimate.SimpleEstimator Estimator algorithm
setOptions
in interface OptionHandler
setOptions
in class Classifier
options
- the list of options as an array of stringsjava.lang.Exception
- if an option is not supportedpublic static java.lang.String[] partitionOptions(java.lang.String[] options)
options
- the input array of optionspublic java.lang.String[] getOptions()
getOptions
in interface OptionHandler
getOptions
in class Classifier
public void setSearchAlgorithm(SearchAlgorithm newSearchAlgorithm)
newSearchAlgorithm
- the SearchAlgorithm to use.public SearchAlgorithm getSearchAlgorithm()
public void setEstimator(BayesNetEstimator newBayesNetEstimator)
newBayesNetEstimator
- the Estimator to use.public BayesNetEstimator getEstimator()
public void setUseADTree(boolean bUseADTree)
bUseADTree
- true if an ADTree structure is usedpublic boolean getUseADTree()
public void setBIFFile(java.lang.String sBIFFile)
sBIFFile
- the name of the BIF filepublic java.lang.String getBIFFile()
public java.lang.String toString()
toString
in class java.lang.Object
public int graphType()
public java.lang.String graph() throws java.lang.Exception
public java.lang.String getBIFHeader()
public java.lang.String toXMLBIF03()
public java.lang.String useADTreeTipText()
public java.lang.String searchAlgorithmTipText()
public java.lang.String estimatorTipText()
public java.lang.String BIFFileTipText()
public java.lang.String globalInfo()
public static void main(java.lang.String[] argv)
argv
- the optionspublic java.lang.String getName()
public int getNrOfNodes()
public java.lang.String getNodeName(int iNode)
iNode
- index of the nodepublic int getCardinality(int iNode)
iNode
- index of the nodepublic java.lang.String getNodeValue(int iNode, int iValue)
iNode
- index of the nodeiValue
- index of the valuepublic int getNrOfParents(int iNode)
iNode
- index of the nodepublic int getParent(int iNode, int iParent)
iNode
- index of the nodeiParent
- index of the parents, e.g., 0 is the first parent, 1 the second parent, etc.public ParentSet[] getParentSets()
public Estimator[][] getDistributions()
public int getParentCardinality(int iNode)
iNode
- index of the nodepublic double getProbability(int iNode, int iParent, int iValue)
iNode
- index of the nodeiParent
- index of the parent set, 0 <= iParent <= getParentCardinality(iNode)iValue
- index of the value, 0 <= iValue <= getCardinality(iNode)public ParentSet getParentSet(int iNode)
iNode
- index of the nodepublic ADNode getADTree()
public java.util.Enumeration enumerateMeasures()
enumerateMeasures
in interface AdditionalMeasureProducer
public double measureExtraArcs()
public double measureMissingArcs()
public double measureReversedArcs()
public double measureDivergence()
public double measureBayesScore()
public double measureBDeuScore()
public double measureMDLScore()
public double measureAICScore()
public double measureEntropyScore()
public double getMeasure(java.lang.String measureName)
getMeasure
in interface AdditionalMeasureProducer
measureName
- the name of the measure to query for its valuejava.lang.IllegalArgumentException
- if the named measure is not supportedpublic java.lang.String getRevision()
getRevision
in interface RevisionHandler
getRevision
in class Classifier