类 BayesNet
java.lang.Object
weka.classifiers.Classifier
weka.classifiers.bayes.BayesNet
- 所有已实现的接口:
Serializable
,Cloneable
,AdditionalMeasureProducer
,CapabilitiesHandler
,Drawable
,OptionHandler
,RevisionHandler
,WeightedInstancesHandler
- 直接已知子类:
BIFReader
,EditableBayesNet
public class BayesNet
extends Classifier
implements OptionHandler, WeightedInstancesHandler, Drawable, AdditionalMeasureProducer
Bayes Network learning using various search algorithms and quality measures.
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.
For more information see:
http://sourceforge.net/projects/weka/files/documentation/WekaManual-3-6-1.pdf/download Valid options are:
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.
For more information see:
http://sourceforge.net/projects/weka/files/documentation/WekaManual-3-6-1.pdf/download 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
- 版本:
- $Revision: 5725 $
- 作者:
- Remco Bouckaert (rrb@xm.co.nz)
- 另请参阅:
-
字段概要
字段修饰符和类型字段说明Estimator[][]
The attribute estimators containing CPTs.The dataset header for the purposes of printing out a semi-intelligible model从接口继承的字段 weka.core.Drawable
BayesNet, Newick, NOT_DRAWABLE, TREE
-
构造器概要
构造器 -
方法概要
修饰符和类型方法说明void
buildClassifier
(Instances instances) Generates the classifier.void
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.Returns an enumeration of the measure names.void
estimateCPTs estimates the conditional probability tables for the Bayes Net using the network structure.This will return a string describing the BayesNetEstimator.get ADTree strucrture containing efficient representation of counts.Get name of network in BIF file to compare withReturns default capabilities of the classifier.int
getCardinality
(int iNode) get number of values a node can takeEstimator[][]
Get full set of estimators.Get the BayesNetEstimator used for calculating the CPTsdouble
getMeasure
(String measureName) Returns the value of the named measuregetName()
get name of the Bayes networkgetNodeName
(int iNode) get name of a node in the Bayes networkgetNodeValue
(int iNode, int iValue) get name of a particular value of a nodeint
get number of nodes in the Bayes networkint
getNrOfParents
(int iNode) get number of parents of a node in the network structureString[]
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 structureint
getParentCardinality
(int iNode) get number of values the collection of parents of a node can takegetParentSet
(int iNode) get the parent set of a nodeGet 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.Returns the revision string.Get the SearchAlgorithm used as the search algorithmboolean
Method declarationThis will return a string describing the classifier.graph()
Returns a BayesNet graph in XMLBIF ver 0.3 format.int
Returns the type of graph this classifier represents.void
initCPTs()
initializes the conditional probabilitiesvoid
Init structure initializes the structure to an empty graph or a Naive Bayes graph (depending on the -N flag).Returns an enumeration describing the available optionsstatic void
Main method for testing this class.double
double
double
double
double
double
double
double
double
static String[]
partitionOptions
(String[] options) Returns the secondary set of options (if any) contained in the supplied options array.void
setBIFFile
(String sBIFFile) Set name of network in BIF file to compare withvoid
setEstimator
(BayesNetEstimator newBayesNetEstimator) Set the Estimator Algorithm used in calculating the CPTsvoid
setOptions
(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 nottoString()
Returns a description of the classifier.Returns a description of the classifier in XML BIF 0.3 format.void
updateClassifier
(Instance instance) Updates the classifier with the given instance.从类继承的方法 weka.classifiers.Classifier
classifyInstance, debugTipText, forName, getDebug, makeCopies, makeCopy, setDebug
-
字段详细资料
-
m_Distributions
The attribute estimators containing CPTs. -
m_Instances
The dataset header for the purposes of printing out a semi-intelligible model
-
-
构造器详细资料
-
BayesNet
public BayesNet()
-
-
方法详细资料
-
getCapabilities
Returns default capabilities of the classifier.- 指定者:
getCapabilities
在接口中CapabilitiesHandler
- 覆盖:
getCapabilities
在类中Classifier
- 返回:
- the capabilities of this classifier
- 另请参阅:
-
buildClassifier
Generates the classifier.- 指定者:
buildClassifier
在类中Classifier
- 参数:
instances
- set of instances serving as training data- 抛出:
Exception
- if the classifier has not been generated successfully
-
initStructure
Init structure initializes the structure to an empty graph or a Naive Bayes graph (depending on the -N flag).- 抛出:
Exception
- in case of an error
-
buildStructure
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.- 抛出:
Exception
- in case of an error
-
estimateCPTs
estimateCPTs estimates the conditional probability tables for the Bayes Net using the network structure.- 抛出:
Exception
- in case of an error
-
initCPTs
initializes the conditional probabilities- 抛出:
Exception
- in case of an error
-
updateClassifier
Updates the classifier with the given instance.- 参数:
instance
- the new training instance to include in the model- 抛出:
Exception
- if the instance could not be incorporated in the model.
-
distributionForInstance
Calculates the class membership probabilities for the given test instance.- 覆盖:
distributionForInstance
在类中Classifier
- 参数:
instance
- the instance to be classified- 返回:
- predicted class probability distribution
- 抛出:
Exception
- if there is a problem generating the prediction
-
countsForInstance
Calculates the counts for Dirichlet distribution for the class membership probabilities for the given test instance.- 参数:
instance
- the instance to be classified- 返回:
- counts for Dirichlet distribution for class probability
- 抛出:
Exception
- if there is a problem generating the prediction
-
listOptions
Returns an enumeration describing the available options- 指定者:
listOptions
在接口中OptionHandler
- 覆盖:
listOptions
在类中Classifier
- 返回:
- an enumeration of all the available options
-
setOptions
Parses a given list of options.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
在接口中OptionHandler
- 覆盖:
setOptions
在类中Classifier
- 参数:
options
- the list of options as an array of strings- 抛出:
Exception
- if an option is not supported
-
partitionOptions
Returns the secondary set of options (if any) contained in the supplied options array. The secondary set is defined to be any options after the first "--" but before the "-E". These options are removed from the original options array.- 参数:
options
- the input array of options- 返回:
- the array of secondary options
-
getOptions
Gets the current settings of the classifier.- 指定者:
getOptions
在接口中OptionHandler
- 覆盖:
getOptions
在类中Classifier
- 返回:
- an array of strings suitable for passing to setOptions
-
setSearchAlgorithm
Set the SearchAlgorithm used in searching for network structures.- 参数:
newSearchAlgorithm
- the SearchAlgorithm to use.
-
getSearchAlgorithm
Get the SearchAlgorithm used as the search algorithm- 返回:
- the SearchAlgorithm used as the search algorithm
-
setEstimator
Set the Estimator Algorithm used in calculating the CPTs- 参数:
newBayesNetEstimator
- the Estimator to use.
-
getEstimator
Get the BayesNetEstimator used for calculating the CPTs- 返回:
- the BayesNetEstimator used.
-
setUseADTree
public void setUseADTree(boolean bUseADTree) Set whether ADTree structure is used or not- 参数:
bUseADTree
- true if an ADTree structure is used
-
getUseADTree
public boolean getUseADTree()Method declaration- 返回:
- whether ADTree structure is used or not
-
setBIFFile
Set name of network in BIF file to compare with- 参数:
sBIFFile
- the name of the BIF file
-
getBIFFile
Get name of network in BIF file to compare with- 返回:
- BIF file name
-
toString
Returns a description of the classifier. -
graphType
public int graphType()Returns the type of graph this classifier represents. -
graph
Returns a BayesNet graph in XMLBIF ver 0.3 format. -
getBIFHeader
-
toXMLBIF03
Returns a description of the classifier in XML BIF 0.3 format. See http://www-2.cs.cmu.edu/~fgcozman/Research/InterchangeFormat/ for details on XML BIF.- 返回:
- an XML BIF 0.3 description of the classifier as a string.
-
useADTreeTipText
- 返回:
- a string to describe the UseADTreeoption.
-
searchAlgorithmTipText
- 返回:
- a string to describe the SearchAlgorithm.
-
estimatorTipText
This will return a string describing the BayesNetEstimator.- 返回:
- The string.
-
BIFFileTipText
- 返回:
- a string to describe the BIFFile.
-
globalInfo
This will return a string describing the classifier.- 返回:
- The string.
-
main
Main method for testing this class.- 参数:
argv
- the options
-
getName
get name of the Bayes network- 返回:
- name of the Bayes net
-
getNrOfNodes
public int getNrOfNodes()get number of nodes in the Bayes network- 返回:
- number of nodes
-
getNodeName
get name of a node in the Bayes network- 参数:
iNode
- index of the node- 返回:
- name of the specified node
-
getCardinality
public int getCardinality(int iNode) get number of values a node can take- 参数:
iNode
- index of the node- 返回:
- cardinality of the specified node
-
getNodeValue
get name of a particular value of a node- 参数:
iNode
- index of the nodeiValue
- index of the value- 返回:
- cardinality of the specified node
-
getNrOfParents
public int getNrOfParents(int iNode) get number of parents of a node in the network structure- 参数:
iNode
- index of the node- 返回:
- number of parents of the specified node
-
getParent
public int getParent(int iNode, int iParent) get node index of a parent of a node in the network structure- 参数:
iNode
- index of the nodeiParent
- index of the parents, e.g., 0 is the first parent, 1 the second parent, etc.- 返回:
- node index of the iParent's parent of the specified node
-
getParentSets
Get full set of parent sets.- 返回:
- parent sets;
-
getDistributions
Get full set of estimators.- 返回:
- estimators;
-
getParentCardinality
public int getParentCardinality(int iNode) get number of values the collection of parents of a node can take- 参数:
iNode
- index of the node- 返回:
- cardinality of the parent set of the specified node
-
getProbability
public double getProbability(int iNode, int iParent, int iValue) get particular probability of the conditional probability distribtion of a node given its parents.- 参数:
iNode
- index of the nodeiParent
- index of the parent set, 0 <= iParent <= getParentCardinality(iNode)iValue
- index of the value, 0 <= iValue <= getCardinality(iNode)- 返回:
- probability
-
getParentSet
get the parent set of a node- 参数:
iNode
- index of the node- 返回:
- Parent set of the specified node.
-
getADTree
get ADTree strucrture containing efficient representation of counts.- 返回:
- ADTree strucrture
-
enumerateMeasures
Returns an enumeration of the measure names. Additional measures must follow the naming convention of starting with "measure", eg. double measureBlah()- 指定者:
enumerateMeasures
在接口中AdditionalMeasureProducer
- 返回:
- an enumeration of the measure names
-
measureExtraArcs
public double measureExtraArcs() -
measureMissingArcs
public double measureMissingArcs() -
measureReversedArcs
public double measureReversedArcs() -
measureDivergence
public double measureDivergence() -
measureBayesScore
public double measureBayesScore() -
measureBDeuScore
public double measureBDeuScore() -
measureMDLScore
public double measureMDLScore() -
measureAICScore
public double measureAICScore() -
measureEntropyScore
public double measureEntropyScore() -
getMeasure
Returns the value of the named measure- 指定者:
getMeasure
在接口中AdditionalMeasureProducer
- 参数:
measureName
- the name of the measure to query for its value- 返回:
- the value of the named measure
- 抛出:
IllegalArgumentException
- if the named measure is not supported
-
getRevision
Returns the revision string.- 指定者:
getRevision
在接口中RevisionHandler
- 覆盖:
getRevision
在类中Classifier
- 返回:
- the revision
-