org.encog.ml.bayesian
public class BayesianNetwork extends BasicML implements MLClassification, MLResettable, Serializable, MLError
Modifier and Type | Field and Description |
---|---|
static String[] |
CHOICES_TRUE_FALSE
Default choices for a boolean event.
|
Constructor and Description |
---|
BayesianNetwork() |
Modifier and Type | Method and Description |
---|---|
double |
calculateError(MLDataSet data)
Calculate the error of the ML method, given a dataset.
|
int |
calculateParameterCount() |
int |
classify(MLData input)
Classify the input.
|
double |
computeProbability(MLData input) |
void |
createDependency(BayesianEvent parentEvent,
BayesianEvent... children)
Create a dependency between a parent and multiple children.
|
void |
createDependency(BayesianEvent parentEvent,
BayesianEvent childEvent)
Create a dependency between two events.
|
void |
createDependency(String parentEventLabel,
String childEventLabel)
Create a dependency between two labels.
|
void |
createEvent(BayesianEvent event)
Create, or register, the specified event with this bayesian network.
|
BayesianEvent |
createEvent(String label,
List<BayesianChoice> options)
Create an event specified on the label and options provided.
|
BayesianEvent |
createEvent(String label,
String... options)
Create the specified events based on a variable number of options, or choices.
|
void |
defineClassificationStructure(String line)
Define a classification structure of the form P(A|B) = P(C)
|
void |
defineProbability(String line)
Define a probability.
|
void |
defineProbability(String line,
double probability)
Define the probability for an event.
|
void |
defineRelationship(String line)
Define a relationship.
|
int[] |
determineClasses(MLData input)
Determine the classes for the specified input.
|
boolean |
eventExists(String label)
Return true if the specified event exists.
|
void |
finalizeStructure()
Finalize the structure of this Bayesian network.
|
String |
getClassificationStructure() |
int |
getClassificationTarget()
Get the classification target.
|
BayesianEvent |
getClassificationTargetEvent() |
String |
getContents() |
BayesianEvent |
getEvent(String label)
Get an event based on the string label.
|
BayesianEvent |
getEventError(String label)
Get an event based on label, throw an error if not found.
|
int |
getEventIndex(BayesianEvent event) |
Map<String,BayesianEvent> |
getEventMap() |
List<BayesianEvent> |
getEvents() |
int |
getInputCount() |
int |
getOutputCount() |
BayesianQuery |
getQuery() |
boolean |
hasValidClassificationTarget() |
boolean |
isCondIndependent(BayesianEvent a,
BayesianEvent b,
BayesianEvent... given) |
boolean |
isDescendant(BayesianEvent a,
BayesianEvent b)
Determine if one event is a descendant of another.
|
boolean |
isInputPresent(int idx)
Determine if the specified input is present.
|
double |
performQuery(String line)
Perform a query.
|
void |
removeAllRelations()
Remove all relations between nodes.
|
BayesianEvent |
requireEvent(String label)
Require the specified event, thrown an error if it does not exist.
|
void |
reset()
Reset the weights.
|
void |
reset(int seed)
Reset the weights with a seed.
|
void |
setContents(String line)
Define the structure of the Bayesian network as a string.
|
void |
setQuery(BayesianQuery query) |
String |
toString() |
void |
updateProperties()
Update any objeccts when a property changes.
|
void |
validate()
Validate the structure of this Bayesian network.
|
getProperties, getPropertyDouble, getPropertyLong, getPropertyString, setProperty, setProperty, setProperty
public static final String[] CHOICES_TRUE_FALSE
public Map<String,BayesianEvent> getEventMap()
public List<BayesianEvent> getEvents()
public BayesianEvent getEvent(String label)
label
- The label to locate.public BayesianEvent getEventError(String label)
label
- THe event label to find.public boolean eventExists(String label)
label
- The label we are searching for.public void createEvent(BayesianEvent event)
event
- The event to add.public BayesianEvent createEvent(String label, List<BayesianChoice> options)
label
- The label to create this event as.options
- The options, or states, that this event can have.public BayesianEvent createEvent(String label, String... options)
label
- The label of the event to create.options
- The states that the event can have.public void createDependency(BayesianEvent parentEvent, BayesianEvent childEvent)
parentEvent
- The parent event.childEvent
- The child event.public void createDependency(BayesianEvent parentEvent, BayesianEvent... children)
parentEvent
- The parent event.children
- The child events.public void createDependency(String parentEventLabel, String childEventLabel)
parentEventLabel
- The parent event.childEventLabel
- The child event.public String getContents()
public void setContents(String line)
line
- The string to define events and relations.public int calculateParameterCount()
public void finalizeStructure()
public void validate()
public boolean isDescendant(BayesianEvent a, BayesianEvent b)
a
- The event to check.b
- The event that has children.public boolean isCondIndependent(BayesianEvent a, BayesianEvent b, BayesianEvent... given)
public BayesianQuery getQuery()
public void setQuery(BayesianQuery query)
public int getInputCount()
getInputCount
in interface MLInput
public int getOutputCount()
getOutputCount
in interface MLOutput
public double computeProbability(MLData input)
public void defineProbability(String line, double probability)
line
- The event.probability
- The probability.public void defineProbability(String line)
line
- The line to define the probability.public BayesianEvent requireEvent(String label)
label
- The label.public void defineRelationship(String line)
line
- The relationship to define.public double performQuery(String line)
line
- The query.public void updateProperties()
updateProperties
in interface MLProperties
updateProperties
in class BasicML
public int getEventIndex(BayesianEvent event)
public void removeAllRelations()
public void reset()
reset
in interface MLResettable
public void reset(int seed)
reset
in interface MLResettable
seed
- The seed value.public int[] determineClasses(MLData input)
input
- The input.public int classify(MLData input)
classify
in interface MLClassification
input
- The input to classify.public int getClassificationTarget()
public boolean isInputPresent(int idx)
idx
- The index of the input.public void defineClassificationStructure(String line)
line
- public BayesianEvent getClassificationTargetEvent()
public double calculateError(MLDataSet data)
calculateError
in interface MLError
data
- The dataset.public String getClassificationStructure()
public boolean hasValidClassificationTarget()
Copyright © 2014. All Rights Reserved.