org.encog.ml.bayesian
Class BayesianEvent
- java.lang.Object
-
- org.encog.ml.bayesian.BayesianEvent
-
- All Implemented Interfaces:
- java.io.Serializable
public class BayesianEvent extends java.lang.Object implements java.io.SerializableEvents 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(java.lang.String theLabel)Construct a boolean event.BayesianEvent(java.lang.String theLabel, java.util.List<BayesianChoice> theChoices)Construct an event with the specified label and choices.BayesianEvent(java.lang.String theLabel, java.lang.String[] theChoices)Construct an event with the specified label and choices.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method and Description voidaddChild(BayesianEvent e)Add a child event.voidaddParent(BayesianEvent e)Add a parent event.intcalculateParameterCount()voidfinalizeStructure()Finalize the structure.static java.lang.StringformatEventName(BayesianEvent event, int value)Format the event name with +, - and =.java.util.List<BayesianEvent>getChildren()BayesianChoicegetChoice(int arg)Return the choice specified by the index.java.util.Set<BayesianChoice>getChoices()java.lang.StringgetLabel()java.util.List<BayesianEvent>getParents()BayesianTablegetTable()booleanhasChildren()booleanhasGiven(java.lang.String l)Return true if the event has the specified given event.booleanhasParents()booleanisBoolean()intmatchChoiceToRange(double d)Match a continuous value to a discrete range.voidremoveAllRelations()Remove all relations.voidreset()Reset the logic table.booleanrollArgs(double[] args)Roll the specified arguments through all of the possible values, return false if we are at the final iteration.java.lang.StringtoFullString()java.lang.StringtoString()voidvalidate()Validate the event.
-
-
-
Constructor Detail
-
BayesianEvent
public BayesianEvent(java.lang.String theLabel, java.util.List<BayesianChoice> theChoices)Construct an event with the specified label and choices.- Parameters:
theLabel- The label.theChoices- The choices, or states.
-
BayesianEvent
public BayesianEvent(java.lang.String theLabel, java.lang.String[] theChoices)Construct an event with the specified label and choices.- Parameters:
theLabel- The label.theChoices- The choices, or states.
-
BayesianEvent
public BayesianEvent(java.lang.String theLabel)
Construct a boolean event.- Parameters:
theLabel- The label.
-
-
Method Detail
-
getParents
public java.util.List<BayesianEvent> getParents()
- Returns:
- the parents
-
getChildren
public java.util.List<BayesianEvent> getChildren()
- Returns:
- the children
-
getLabel
public java.lang.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 java.lang.String toFullString()
- Returns:
- A full string that contains all info for this event.
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
calculateParameterCount
public int calculateParameterCount()
- Returns:
- The parameter count.
-
getChoices
public java.util.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 java.lang.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(java.lang.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.
-
-
DMelt 3.0 © DataMelt by jWork.ORG