org.encog.ml.bayesian

## Class BayesianEvent

- java.lang.Object
- - org.encog.ml.bayesian.BayesianEvent

- All Implemented Interfaces:
    Serializable

      public class BayesianEvent
      extends Object
      implements Serializable

  Events make up a Bayesian network. Each evidence or outcome event usually corresponds to one number in the training data. A event is always discrete. However, continues values can be range-mapped to discrete values.
  See Also:
    Serialized Form

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `BayesianEvent(String theLabel)` Construct a boolean event.
    `BayesianEvent(String theLabel, List<BayesianChoice> theChoices)` Construct an event with the specified label and choices.
    `BayesianEvent(String theLabel, String[] theChoices)` Construct an event with the specified label and choices.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addChild(BayesianEvent e)` Add a child event.
    `void` | `addParent(BayesianEvent e)` Add a parent event.
    `int` | `calculateParameterCount()`
    `void` | `finalizeStructure()` Finalize the structure.
    `static String` | `formatEventName(BayesianEvent event, int value)` Format the event name with +, - and =.
    `List<BayesianEvent>` | `getChildren()`
    `BayesianChoice` | `getChoice(int arg)` Return the choice specified by the index.
    `Set<BayesianChoice>` | `getChoices()`
    `String` | `getLabel()`
    `List<BayesianEvent>` | `getParents()`
    `BayesianTable` | `getTable()`
    `boolean` | `hasChildren()`
    `boolean` | `hasGiven(String l)` Return true if the event has the specified given event.
    `boolean` | `hasParents()`
    `boolean` | `isBoolean()`
    `int` | `matchChoiceToRange(double d)` Match a continuous value to a discrete range.
    `void` | `removeAllRelations()` Remove all relations.
    `void` | `reset()` Reset the logic table.
    `boolean` | `rollArgs(double[] args)` Roll the specified arguments through all of the possible values, return false if we are at the final iteration.
    `String` | `toFullString()`
    `String` | `toString()`
    `void` | `validate()` Validate the event.

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

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

- - ### Constructor Detail

    - #### BayesianEvent

          public BayesianEvent(String theLabel,
                       List<BayesianChoice> theChoices)

      Construct an event with the specified label and choices.
      Parameters:
        `theLabel` - The label.
        `theChoices` - The choices, or states.

    - #### BayesianEvent

          public BayesianEvent(String theLabel,
                       String[] theChoices)

      Construct an event with the specified label and choices.
      Parameters:
        `theLabel` - The label.
        `theChoices` - The choices, or states.

    - #### BayesianEvent

          public BayesianEvent(String theLabel)

      Construct a boolean event.
      Parameters:
        `theLabel` - The label.

  - ### Method Detail

    - #### getParents

          public List<BayesianEvent> getParents()

      Returns:
        the parents

    - #### getChildren

          public List<BayesianEvent> getChildren()

      Returns:
        the children

    - #### getLabel

          public String getLabel()

      Returns:
        the label

    - #### addChild

          public void addChild(BayesianEvent e)

      Add a child event.
      Parameters:
        `e` - The child event.

    - #### addParent

          public void addParent(BayesianEvent e)

      Add a parent event.
      Parameters:
        `e` - The parent event.

    - #### hasParents

          public boolean hasParents()

      Returns:
        True, if this event has parents.

    - #### hasChildren

          public boolean hasChildren()

      Returns:
        True, if this event has parents.

    - #### toFullString

          public String toFullString()

      Returns:
        A full string that contains all info for this event.

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`

    - #### calculateParameterCount

          public int calculateParameterCount()

      Returns:
        The parameter count.

    - #### getChoices

          public Set<BayesianChoice> getChoices()

      Returns:
        the choices

    - #### getTable

          public BayesianTable getTable()

      Returns:
        the table

    - #### finalizeStructure

          public void finalizeStructure()

      Finalize the structure.

    - #### validate

          public void validate()

      Validate the event.

    - #### isBoolean

          public boolean isBoolean()

      Returns:
        True, if this is a boolean event.

    - #### rollArgs

          public boolean rollArgs(double[] args)

      Roll the specified arguments through all of the possible values, return false if we are at the final iteration. This is used to enumerate through all of the possible argument values of this event.
      Parameters:
        `args` - The arguments to enumerate.
      Returns:
        True if there are more iterations.

    - #### removeAllRelations

          public void removeAllRelations()

      Remove all relations.

    - #### formatEventName

          public static String formatEventName(BayesianEvent event,
                               int value)

      Format the event name with +, - and =. For example +a or -1, or a=red.
      Parameters:
        `event` - The event to format.
        `value` - The value to format for.
      Returns:
        The formatted name.

    - #### hasGiven

          public boolean hasGiven(String l)

      Return true if the event has the specified given event.
      Parameters:
        `l` - The event to check for.
      Returns:
        True if the event has the specified given.

    - #### reset

          public void reset()

      Reset the logic table.

    - #### matchChoiceToRange

          public int matchChoiceToRange(double d)

      Match a continuous value to a discrete range. This is how floating point numbers can be used as input to a Bayesian network.
      Parameters:
        `d` - The continuous value.
      Returns:
        The range that the value was mapped into.

    - #### getChoice

          public BayesianChoice getChoice(int arg)

      Return the choice specified by the index. This requires searching through a list. Do not call in performance critical areas.
      Parameters:
        `arg` - The argument number.
      Returns:
        The bayesian choice found.

Copyright © 2014. All Rights Reserved.