weka.classifiers.bayes.net

## Class BayesNetGenerator

- java.lang.Object
- - weka.classifiers.AbstractClassifier
  - - weka.classifiers.bayes.BayesNet
    - - weka.classifiers.bayes.net.EditableBayesNet
      - - weka.classifiers.bayes.net.BayesNetGenerator

- All Implemented Interfaces:
    java.io.Serializable, java.lang.Cloneable, Classifier, AdditionalMeasureProducer, CapabilitiesHandler, CapabilitiesIgnorer, Drawable, OptionHandler, RevisionHandler, WeightedInstancesHandler

      public class BayesNetGenerator
      extends EditableBayesNet

  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:

       -B
        Generate network (instead of instances)

       -N <integer>
        Nr of nodes

       -A <integer>
        Nr of arcs

       -M <integer>
        Nr of instances

       -C <integer>
        Cardinality of the variables

       -S <integer>
        Seed for random number generator

       -F <file>
        The BIF file to obtain the structure from.

  Version:
    $Revision: 10153 $
  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, Newick, NOT_DRAWABLE, TREE`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `BayesNetGenerator()` Constructor for BayesNetGenerator.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `generateInstances()` GenerateInstances generates random instances sampling from the distribution represented by the Bayes network structure.
    `void` | `generateRandomNetwork()` Generate random connected Bayesian network with discrete nodes having all the same cardinality.
    `void` | `generateRandomNetworkStructure(int nNodes, int nArcs)` GenerateRandomNetworkStructure generate random connected Bayesian network
    `java.lang.String[]` | `getOptions()` Gets the current settings of the classifier.
    `java.lang.String` | `getRevision()` Returns the revision string.
    `void` | `Init(int nNodes, int nValues)` Init defines a minimal Bayes net with no arcs
    `java.util.Enumeration<Option>` | `listOptions()` Returns an enumeration describing the available options
    `static void` | `main(java.lang.String[] args)` Main method
    `void` | `setOptions(java.lang.String[] options)` Parses a given list of options.
    `java.lang.String` | `toString()` Returns either the net (if BIF format) or the generated instances

    - ### Methods inherited from class weka.classifiers.bayes.net.EditableBayesNet

      `addArc, addArc, addArc, addNode, addNode, addNodeValue, alignBottom, alignLeft, alignRight, alignTop, canRedo, canUndo, centerHorizontal, centerVertical, clearUndoStack, deleteArc, deleteArc, deleteNode, deleteNode, deleteSelection, delNodeValue, getChildren, getContent, getDistribution, getDistribution, getEvidence, getMargin, getNode, getNode2, getPositionX, getPositionY, getValueName, getValues, getValues, isChanged, isSaved, lastActionMsg, layoutGraph, paste, redo, renameNodeValue, setData, setDistribution, setDistribution, setEvidence, setMargin, setNodeName, setPosition, setPosition, spaceHorizontal, spaceVertical, toXMLBIF03, toXMLBIF03, undo`

    - ### Methods inherited from class weka.classifiers.bayes.BayesNet

      `BIFFileTipText, buildClassifier, buildStructure, countsForInstance, distributionForInstance, enumerateMeasures, estimateCPTs, estimatorTipText, getADTree, getBIFFile, getBIFHeader, getCapabilities, getCardinality, getDistributions, getEstimator, getMeasure, getName, getNodeName, getNodeValue, getNrOfNodes, getNrOfParents, getNumInstances, getParent, getParentCardinality, getParentSet, getParentSets, getProbability, getSearchAlgorithm, getUseADTree, globalInfo, graph, graphType, initCPTs, initStructure, measureAICScore, measureBayesScore, measureBDeuScore, measureDivergence, measureEntropyScore, measureExtraArcs, measureMDLScore, measureMissingArcs, measureReversedArcs, partitionOptions, searchAlgorithmTipText, setBIFFile, setEstimator, setSearchAlgorithm, setUseADTree, updateClassifier, useADTreeTipText`

    - ### Methods inherited from class weka.classifiers.AbstractClassifier

      `classifyInstance, debugTipText, doNotCheckCapabilitiesTipText, forName, getDebug, getDoNotCheckCapabilities, makeCopies, makeCopy, runClassifier, setDebug, setDoNotCheckCapabilities`

    - ### Methods inherited from class java.lang.Object

      `equals, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### BayesNetGenerator

          public BayesNetGenerator()

      Constructor for BayesNetGenerator.

  - ### Method Detail

    - #### generateRandomNetwork

          public void generateRandomNetwork()
                                     throws java.lang.Exception

      Generate random connected Bayesian network with discrete nodes having all the same cardinality.
      Throws:
        `java.lang.Exception` - if something goes wrong

    - #### Init

          public void Init(int nNodes,
                  int nValues)
                    throws java.lang.Exception

      Init defines a minimal Bayes net with no arcs
      Parameters:
        `nNodes` - number of nodes in the Bayes net
        `nValues` - number of values each of the nodes can take
      Throws:
        `java.lang.Exception` - if something goes wrong

    - #### generateRandomNetworkStructure

          public void generateRandomNetworkStructure(int nNodes,
                                            int nArcs)
                                              throws java.lang.Exception

      GenerateRandomNetworkStructure generate random connected Bayesian network
      Parameters:
        `nNodes` - number of nodes in the Bayes net to generate
        `nArcs` - number of arcs to generate. Must be between nNodes - 1 and nNodes * (nNodes-1) / 2
      Throws:
        `java.lang.Exception` - if number of arcs is incorrect

    - #### generateInstances

          public void generateInstances()
                                 throws java.lang.Exception

      GenerateInstances generates random instances sampling from the distribution represented by the Bayes network structure. It assumes a Bayes network structure has been initialized
      Throws:
        `java.lang.Exception` - if something goes wrong

    - #### toString

          public java.lang.String toString()

      Returns either the net (if BIF format) or the generated instances
      Overrides:
        `toString` in class `BayesNet`
      Returns:
        either the net or the generated instances

    - #### listOptions

          public java.util.Enumeration<Option> listOptions()

      Returns an enumeration describing the available options
      Specified by:
        `listOptions` in interface `OptionHandler`
      Overrides:
        `listOptions` in class `BayesNet`
      Returns:
        an enumeration of all the available options

    - #### setOptions

          public void setOptions(java.lang.String[] options)
                          throws java.lang.Exception

      Parses a given list of options.

      Valid options are:

           -B
            Generate network (instead of instances)

           -N <integer>
            Nr of nodes

           -A <integer>
            Nr of arcs

           -M <integer>
            Nr of instances

           -C <integer>
            Cardinality of the variables

           -S <integer>
            Seed for random number generator

           -F <file>
            The BIF file to obtain the structure from.

      Specified by:
        `setOptions` in interface `OptionHandler`
      Overrides:
        `setOptions` in class `BayesNet`
      Parameters:
        `options` - the list of options as an array of strings
      Throws:
        `java.lang.Exception` - if an option is not supported

    - #### getOptions

          public java.lang.String[] getOptions()

      Gets the current settings of the classifier.
      Specified by:
        `getOptions` in interface `OptionHandler`
      Overrides:
        `getOptions` in class `BayesNet`
      Returns:
        an array of strings suitable for passing to setOptions

    - #### getRevision

          public java.lang.String getRevision()

      Returns the revision string.
      Specified by:
        `getRevision` in interface `RevisionHandler`
      Overrides:
        `getRevision` in class `EditableBayesNet`
      Returns:
        the revision

    - #### main

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

      Main method
      Parameters:
        `args` - the commandline parameters