Class BayesNetGenerator

    • Constructor Detail

      • BayesNetGenerator

        public BayesNetGenerator()
        Constructor for BayesNetGenerator.
    • Method Detail

      • generateRandomNetwork

        public void generateRandomNetwork()
                                   throws Exception
        Generate random connected Bayesian network with discrete nodes having all the same cardinality.
        Throws:
        Exception - if something goes wrong
      • Init

        public void Init​(int nNodes,
                         int nValues)
                  throws 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:
        Exception - if something goes wrong
      • generateRandomNetworkStructure

        public void generateRandomNetworkStructure​(int nNodes,
                                                   int nArcs)
                                            throws 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:
        Exception - if number of arcs is incorrect
      • generateInstances

        public void generateInstances()
                               throws 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:
        Exception - if something goes wrong
      • toString

        public 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
      • setOptions

        public void setOptions​(String[] options)
                        throws 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:
        Exception - if an option is not supported
      • getOptions

        public 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
      • main

        public static void main​(String[] args)
        Main method
        Parameters:
        args - the commandline parameters