weka.classifiers.bayes.net
Class BIFReader

java.lang.Object
  extended by weka.classifiers.Classifier
      extended by weka.classifiers.bayes.BayesNet
          extended by weka.classifiers.bayes.net.BIFReader
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, AdditionalMeasureProducer, Drawable, OptionHandler, WeightedInstancesHandler

public class BIFReader
extends BayesNet

Builds a description of a Bayes Net classifier stored in XML BIF 0.3 format. See http://www-2.cs.cmu.edu/~fgcozman/Research/InterchangeFormat/ for details on XML BIF.

Version:
$Revision: 1.7.2.1 $
Author:
Remco Bouckaert (rrb@xm.co.nz)
See Also:
Serialized Form

Field Summary
 
Fields inherited from class weka.classifiers.bayes.BayesNet
m_Distributions, m_Instances
 
Fields inherited from interface weka.core.Drawable
BayesNet, NOT_DRAWABLE, TREE
 
Constructor Summary
BIFReader()
           
 
Method Summary
 double divergence(BayesNet other)
          calculates the divergence between the probability distribution represented by this network and that of another, that is, \sum_{x\in X} P(x)log P(x)/Q(x) where X is the set of values the nodes in the network can take, P(x) the probability of this network for configuration x Q(x) the probability of the other network for configuration x
 int extraArcs(BayesNet other)
          Count nr of exta arcs from other network compared to current network Note that an arc is not 'extra' if it is reversed.
 java.lang.String getContent(org.w3c.dom.Element node)
          Returns all TEXT children of the given node in one string.
 java.lang.String getFileName()
           
 int getNode(java.lang.String sNodeName)
          getNode finds the index of the node with name sNodeName and throws an exception if no such node can be found.
static void main(java.lang.String[] args)
           
 int missingArcs(BayesNet other)
          Count nr of arcs missing from other network compared to current network Note that an arc is not 'missing' if it is reversed.
 BIFReader processFile(java.lang.String sFile)
          processFile reads a BIFXML file and initializes a Bayes Net
 int reversedArcs(BayesNet other)
          Count nr of reversed arcs from other network compared to current network
 void Sync(BayesNet other)
          synchronizes the node ordering of this Bayes network with those in the other network (if possible).
 
Methods inherited from class weka.classifiers.bayes.BayesNet
BIFFileTipText, buildClassifier, buildStructure, countsForInstance, distributionForInstance, enumerateMeasures, estimateCPTs, estimatorTipText, getADTree, getBIFFile, getCardinality, getDistributions, getEstimator, getMeasure, getName, getNodeName, getNodeValue, getNrOfNodes, getNrOfParents, getOptions, getParent, getParentCardinality, getParentSet, getParentSets, getProbability, getSearchAlgorithm, getUseADTree, globalInfo, graph, graphType, initCPTs, initStructure, listOptions, measureAICScore, measureBayesScore, measureBDeuScore, measureDivergence, measureEntropyScore, measureExtraArcs, measureMDLScore, measureMissingArcs, measureReversedArcs, partitionOptions, searchAlgorithmTipText, setBIFFile, setEstimator, setOptions, setSearchAlgorithm, setUseADTree, toString, toXMLBIF03, updateClassifier, useADTreeTipText
 
Methods inherited from class weka.classifiers.Classifier
classifyInstance, debugTipText, forName, getDebug, makeCopies, makeCopy, setDebug
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

BIFReader

public BIFReader()
Method Detail

processFile

public BIFReader processFile(java.lang.String sFile)
                      throws java.lang.Exception
processFile reads a BIFXML file and initializes a Bayes Net

Parameters:
sFile: - name of the file to parse
Throws:
java.lang.Exception

getFileName

public java.lang.String getFileName()

Sync

public void Sync(BayesNet other)
          throws java.lang.Exception
synchronizes the node ordering of this Bayes network with those in the other network (if possible).

Parameters:
other: - Bayes network to synchronize with
Throws:
java.lang.Exception - if nr of attributes differs or not all of the variables have the same name.

getNode

public int getNode(java.lang.String sNodeName)
            throws java.lang.Exception
getNode finds the index of the node with name sNodeName and throws an exception if no such node can be found.

Parameters:
sNodeName: - name of the node to get the index from
Returns:
index of the node with name sNodeName
Throws:
java.lang.Exception

getContent

public java.lang.String getContent(org.w3c.dom.Element node)
Returns all TEXT children of the given node in one string. Between the node values new lines are inserted.


missingArcs

public int missingArcs(BayesNet other)
Count nr of arcs missing from other network compared to current network Note that an arc is not 'missing' if it is reversed.

Parameters:
other: - network to compare with
Returns:
nr of missing arcs

extraArcs

public int extraArcs(BayesNet other)
Count nr of exta arcs from other network compared to current network Note that an arc is not 'extra' if it is reversed.

Parameters:
other: - network to compare with
Returns:
nr of missing arcs

divergence

public double divergence(BayesNet other)
calculates the divergence between the probability distribution represented by this network and that of another, that is, \sum_{x\in X} P(x)log P(x)/Q(x) where X is the set of values the nodes in the network can take, P(x) the probability of this network for configuration x Q(x) the probability of the other network for configuration x

Parameters:
other: - network to compare with
Returns:
divergence between this and other Bayes Network

reversedArcs

public int reversedArcs(BayesNet other)
Count nr of reversed arcs from other network compared to current network

Parameters:
other: - network to compare with
Returns:
nr of missing arcs

main

public static void main(java.lang.String[] args)