类 EditableBayesNet

所有已实现的接口:
Serializable, Cloneable, AdditionalMeasureProducer, CapabilitiesHandler, Drawable, OptionHandler, RevisionHandler, WeightedInstancesHandler
直接已知子类:
BayesNetGenerator

public class EditableBayesNet extends BayesNet
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://www.cs.waikato.ac.nz/~remco/weka.pdf

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: 7836 $
作者:
Remco Bouckaert (rrb@xm.co.nz)
另请参阅:
  • 构造器详细资料

    • EditableBayesNet

      public EditableBayesNet()
      standard constructor *
    • EditableBayesNet

      public EditableBayesNet(Instances instances)
      constructor, creates empty network with nodes based on the attributes in a data set
    • EditableBayesNet

      public EditableBayesNet(BIFReader other)
      constructor, copies Bayesian network structure from a Bayesian network encapsulated in a BIFReader
    • EditableBayesNet

      public EditableBayesNet(boolean bSetInstances)
      constructor that potentially initializes instances as well
      参数:
      bSetInstances - flag indicating whether to initialize instances or not
  • 方法详细资料

    • setData

      public void setData(Instances instances) throws Exception
      Assuming a network structure is defined and we want to learn from data, the data set must be put if correct order first and possibly discretized/missing values filled in before proceeding to CPT learning.
      参数:
      instances - data set to learn from
      抛出:
      Exception - when data sets are not compatible, e.g., a variable is missing or a variable has different nr of values.
    • getNode2

      public int getNode2(String sNodeName)
      returns index of node with given name, or -1 if no such node exists
      参数:
      sNodeName - name of the node to get index for
    • getNode

      public int getNode(String sNodeName) throws Exception
      returns index of node with given name. Throws exception if no such node exists
      参数:
      sNodeName - name of the node to get index for
      抛出:
      Exception
    • addNode

      public void addNode(String sName, int nCardinality) throws Exception
      Add new node to the network, initializing instances, parentsets, distributions. Used for manual manipulation of the Bayesian network.
      参数:
      sName - name of the node. If the name already exists, an x is appended to the name
      nCardinality - number of values for this node
      抛出:
      Exception
    • addNode

      public void addNode(String sName, int nCardinality, int nPosX, int nPosY) throws Exception
      Add node to network at a given position, initializing instances, parentsets, distributions. Used for manual manipulation of the Bayesian network.
      参数:
      sName - name of the node. If the name already exists, an x is appended to the name
      nCardinality - number of values for this node
      nPosX - x-coordiate of the position to place this node
      nPosY - y-coordiate of the position to place this node
      抛出:
      Exception
    • deleteNode

      public void deleteNode(String sName) throws Exception
      Delete node from the network, updating instances, parentsets, distributions Conditional distributions are condensed by taking the values for the target node to be its first value. Used for manual manipulation of the Bayesian network.
      参数:
      sName - name of the node. If the name does not exists an exception is thrown
      抛出:
      Exception
    • deleteNode

      public void deleteNode(int nTargetNode) throws Exception
      Delete node from the network, updating instances, parentsets, distributions Conditional distributions are condensed by taking the values for the target node to be its first value. Used for manual manipulation of the Bayesian network.
      参数:
      nTargetNode - index of the node to delete.
      抛出:
      Exception
    • deleteSelection

      public void deleteSelection(FastVector nodes)
      Delete nodes with indexes in selection from the network, updating instances, parentsets, distributions Conditional distributions are condensed by taking the values for the target node to be its first value. Used for manual manipulation of the Bayesian network.
      参数:
      nodes - array of indexes of nodes to delete.
      抛出:
      Exception
    • getContent

      public String getContent(Element node)
      XML helper function. Returns all TEXT children of the given node in one string. Between the node values new lines are inserted.
      参数:
      node - the node to return the content for
      返回:
      the content of the node
    • paste

      public void paste(String sXML) throws Exception
      Apply paste operation with XMLBIF fragment. This adds nodes in the XMLBIF fragment to the network, together with its parents. First, paste in test mode to verify no problems occur, then execute paste operation. If a problem occurs (e.g. parent does not exist) then a exception is thrown.
      参数:
      sXML - XMLBIF fragment to paste into the network
      抛出:
      Exception
    • addArc

      public void addArc(String sParent, String sChild) throws Exception
      Add arc between two nodes Distributions are updated by duplication for every value of the parent node.
      参数:
      sParent - name of the parent node
      sChild - name of the child node
      抛出:
      Exception - if parent or child cannot be found in network
    • addArc

      public void addArc(int nParent, int nChild) throws Exception
      Add arc between two nodes Distributions are updated by duplication for every value of the parent node.
      参数:
      nParent - index of the parent node
      nChild - index of the child node
      抛出:
      Exception
    • addArc

      public void addArc(String sParent, FastVector nodes) throws Exception
      Add arc between parent node and each of the nodes in a given list. Distributions are updated as above.
      参数:
      sParent - name of the parent node
      nodes - array of indexes of child nodes
      抛出:
      Exception
    • deleteArc

      public void deleteArc(String sParent, String sChild) throws Exception
      Delete arc between two nodes. Distributions are updated by condensing for the parent node taking its first value.
      参数:
      sParent - name of the parent node
      sChild - name of the child node
      抛出:
      Exception - if parent or child cannot be found in network
    • deleteArc

      public void deleteArc(int nParent, int nChild) throws Exception
      Delete arc between two nodes. Distributions are updated by condensing for the parent node taking its first value.
      参数:
      nParent - index of the parent node
      nChild - index of the child node
      抛出:
      Exception
    • setDistribution

      public void setDistribution(String sName, double[][] P) throws Exception
      specify distribution of a node
      参数:
      sName - name of the node to specify distribution for
      P - matrix representing distribution with P[i][j] = P(node = j | parent configuration = i)
      抛出:
      Exception - if parent or child cannot be found in network
    • setDistribution

      public void setDistribution(int nTargetNode, double[][] P) throws Exception
      specify distribution of a node
      参数:
      nTargetNode - index of the node to specify distribution for
      P - matrix representing distribution with P[i][j] = P(node = j | parent configuration = i)
      抛出:
      Exception - if parent or child cannot be found in network
    • getDistribution

      public double[][] getDistribution(String sName)
      returns distribution of a node in matrix form with matrix representing distribution with P[i][j] = P(node = j | parent configuration = i)
      参数:
      sName - name of the node to get distribution from
    • getDistribution

      public double[][] getDistribution(int nTargetNode)
      returns distribution of a node in matrix form with matrix representing distribution with P[i][j] = P(node = j | parent configuration = i)
      参数:
      nTargetNode - index of the node to get distribution from
    • getValues

      public String[] getValues(String sName)
      returns array of values of a node
      参数:
      sName - name of the node to get values from
    • getValues

      public String[] getValues(int nTargetNode)
      returns array of values of a node
      参数:
      nTargetNode - index of the node to get values from
    • getValueName

      public String getValueName(int nTargetNode, int iValue)
      returns value of a node
      参数:
      nTargetNode - index of the node to get values from
      iValue - index of the value
    • setNodeName

      public void setNodeName(int nTargetNode, String sName)
      change the name of a node
      参数:
      nTargetNode - index of the node to set name for
      sName - new name to assign
    • renameNodeValue

      public void renameNodeValue(int nTargetNode, String sValue, String sNewValue)
      change the name of a value of a node
      参数:
      nTargetNode - index of the node to set name for
      sValue - current name of the value
      sNewValue - new name of the value
    • addNodeValue

      public void addNodeValue(int nTargetNode, String sNewValue)
      Add node value to a node. Distributions for the node assign zero probability to the new value. Child nodes duplicate CPT conditioned on the new value.
      参数:
      nTargetNode - index of the node to add value for
      sNewValue - name of the value
    • delNodeValue

      public void delNodeValue(int nTargetNode, String sValue) throws Exception
      Delete node value from a node. Distributions for the node are scaled up proportional to existing distribution (or made uniform if zero probability is assigned to remainder of values). .* Child nodes delete CPTs conditioned on the new value.
      参数:
      nTargetNode - index of the node to delete value from
      sValue - name of the value to delete
      抛出:
      Exception
    • setPosition

      public void setPosition(int iNode, int nX, int nY)
      set position of node
      参数:
      iNode - index of node to set position for
      nX - x position of new position
      nY - y position of new position
    • setPosition

      public void setPosition(int nNode, int nX, int nY, FastVector nodes)
      Set position of node. Move set of nodes with the same displacement as a specified node.
      参数:
      iNode - index of node to set position for
      nX - x position of new position
      nY - y position of new position
      nodes - array of indexes of nodes to move
    • layoutGraph

      public void layoutGraph(FastVector nPosX, FastVector nPosY)
      set positions of all nodes
      参数:
      nPosX - new x positions for all nodes
      nPosY - new y positions for all nodes
    • getPositionX

      public int getPositionX(int iNode)
      get x position of a node
      参数:
      iNode - index of node of interest
    • getPositionY

      public int getPositionY(int iNode)
      get y position of a node
      参数:
      iNode - index of node of interest
    • alignLeft

      public void alignLeft(FastVector nodes)
      align set of nodes with the left most node in the list
      参数:
      nodes - list of indexes of nodes to align
    • alignRight

      public void alignRight(FastVector nodes)
      align set of nodes with the right most node in the list
      参数:
      nodes - list of indexes of nodes to align
    • alignTop

      public void alignTop(FastVector nodes)
      align set of nodes with the top most node in the list
      参数:
      nodes - list of indexes of nodes to align
    • alignBottom

      public void alignBottom(FastVector nodes)
      align set of nodes with the bottom most node in the list
      参数:
      nodes - list of indexes of nodes to align
    • centerHorizontal

      public void centerHorizontal(FastVector nodes)
      center set of nodes half way between left and right most node in the list
      参数:
      nodes - list of indexes of nodes to center
    • centerVertical

      public void centerVertical(FastVector nodes)
      center set of nodes half way between top and bottom most node in the list
      参数:
      nodes - list of indexes of nodes to center
    • spaceHorizontal

      public void spaceHorizontal(FastVector nodes)
      space out set of nodes evenly between left and right most node in the list
      参数:
      nodes - list of indexes of nodes to space out
    • spaceVertical

      public void spaceVertical(FastVector nodes)
      space out set of nodes evenly between top and bottom most node in the list
      参数:
      nodes - list of indexes of nodes to space out
    • getMargin

      public double[] getMargin(int iNode)
      return marginal distibution for a node
      参数:
      iNode - index of node of interest
    • setMargin

      public void setMargin(int iNode, double[] fMarginP)
      set marginal distibution for a node
      参数:
      iNode - index of node to set marginal distribution for
      fMarginP - marginal distribution
    • getEvidence

      public int getEvidence(int iNode)
      get evidence state of a node. -1 represents no evidence set, otherwise the index of a value of the node
      参数:
      iNode - index of node of interest
    • setEvidence

      public void setEvidence(int iNode, int iValue)
      set evidence state of a node. -1 represents no evidence set, otherwise the index of a value of the node
      参数:
      iNode - index of node of interest
      iValue - evidence value to set
    • getChildren

      public FastVector getChildren(int nTargetNode)
      return list of children of a node
      参数:
      iNode - index of node of interest
    • toXMLBIF03

      public String toXMLBIF03()
      returns network in XMLBIF format
      覆盖:
      toXMLBIF03 在类中 BayesNet
      返回:
      an XML BIF 0.3 description of the classifier as a string.
    • toXMLBIF03

      public String toXMLBIF03(FastVector nodes)
      return fragment of network in XMLBIF format
      参数:
      nodes - array of indexes of nodes that should be in the fragment
    • canUndo

      public boolean canUndo()
      return whether there is something on the undo stack that can be performed
    • canRedo

      public boolean canRedo()
      return whether there is something on the undo stack that can be performed
    • isChanged

      public boolean isChanged()
      return true when current state differs from the state the network was last saved
    • isSaved

      public void isSaved()
      indicate the network state was saved
    • lastActionMsg

      public String lastActionMsg()
      get message representing the last action performed on the network
    • undo

      public String undo()
      undo the last edit action performed on the network. returns message representing the action performed.
    • redo

      public String redo()
      redo the last edit action performed on the network. returns message representing the action performed.
    • clearUndoStack

      public void clearUndoStack()
      remove all actions from the undo stack
    • getRevision

      public String getRevision()
      Returns the revision string.
      指定者:
      getRevision 在接口中 RevisionHandler
      覆盖:
      getRevision 在类中 BayesNet
      返回:
      the revision
    • main

      public static void main(String[] args)
      参数:
      args -