BayesianNetwork
org.encog.ml.bayesian

Class BayesianNetwork

    • Field Detail

      • CHOICES_TRUE_FALSE

        public static final String[] CHOICES_TRUE_FALSE
        Default choices for a boolean event.
    • Constructor Detail

      • BayesianNetwork

        public BayesianNetwork()
    • Method Detail

      • getEvent

        public BayesianEvent getEvent(String label)
        Get an event based on the string label.
        Parameters:
        label - The label to locate.
        Returns:
        The event found.
      • getEventError

        public BayesianEvent getEventError(String label)
        Get an event based on label, throw an error if not found.
        Parameters:
        label - THe event label to find.
        Returns:
        The event.
      • eventExists

        public boolean eventExists(String label)
        Return true if the specified event exists.
        Parameters:
        label - The label we are searching for.
        Returns:
        True, if the event exists by label.
      • createEvent

        public void createEvent(BayesianEvent event)
        Create, or register, the specified event with this bayesian network.
        Parameters:
        event - The event to add.
      • createEvent

        public BayesianEvent createEvent(String label,                        List<BayesianChoice> options)
        Create an event specified on the label and options provided.
        Parameters:
        label - The label to create this event as.
        options - The options, or states, that this event can have.
        Returns:
        The newly created event.
      • createEvent

        public BayesianEvent createEvent(String label,                        String... options)
        Create the specified events based on a variable number of options, or choices.
        Parameters:
        label - The label of the event to create.
        options - The states that the event can have.
        Returns:
        The newly created event.
      • createDependency

        public void createDependency(BayesianEvent parentEvent,                    BayesianEvent childEvent)
        Create a dependency between two events.
        Parameters:
        parentEvent - The parent event.
        childEvent - The child event.
      • createDependency

        public void createDependency(BayesianEvent parentEvent,                    BayesianEvent... children)
        Create a dependency between a parent and multiple children.
        Parameters:
        parentEvent - The parent event.
        children - The child events.
      • createDependency

        public void createDependency(String parentEventLabel,                    String childEventLabel)
        Create a dependency between two labels.
        Parameters:
        parentEventLabel - The parent event.
        childEventLabel - The child event.
      • getContents

        public String getContents()
        Returns:
        The contents as a string. Shows both events and dependences.
      • setContents

        public void setContents(String line)
        Define the structure of the Bayesian network as a string.
        Parameters:
        line - The string to define events and relations.
      • calculateParameterCount

        public int calculateParameterCount()
        Returns:
        The number of parameters in this Bayesian network.
      • finalizeStructure

        public void finalizeStructure()
        Finalize the structure of this Bayesian network.
      • validate

        public void validate()
        Validate the structure of this Bayesian network.
      • isDescendant

        public boolean isDescendant(BayesianEvent a,                   BayesianEvent b)
        Determine if one event is a descendant of another.
        Parameters:
        a - The event to check.
        b - The event that has children.
        Returns:
        True if a is amoung b's children.
      • getInputCount

        public int getInputCount()
        Specified by:
        getInputCount in interface MLInput
        Returns:
        The input.
      • getOutputCount

        public int getOutputCount()
        Specified by:
        getOutputCount in interface MLOutput
        Returns:
        The output count.
      • computeProbability

        public double computeProbability(MLData input)
      • defineProbability

        public void defineProbability(String line,                     double probability)
        Define the probability for an event.
        Parameters:
        line - The event.
        probability - The probability.
      • defineProbability

        public void defineProbability(String line)
        Define a probability.
        Parameters:
        line - The line to define the probability.
      • requireEvent

        public BayesianEvent requireEvent(String label)
        Require the specified event, thrown an error if it does not exist.
        Parameters:
        label - The label.
        Returns:
        The event.
      • defineRelationship

        public void defineRelationship(String line)
        Define a relationship.
        Parameters:
        line - The relationship to define.
      • performQuery

        public double performQuery(String line)
        Perform a query.
        Parameters:
        line - The query.
        Returns:
        The probability.
      • removeAllRelations

        public void removeAllRelations()
        Remove all relations between nodes.
      • reset

        public void reset()
        Reset the weights.
        Specified by:
        reset in interface MLResettable
      • reset

        public void reset(int seed)
        Reset the weights with a seed.
        Specified by:
        reset in interface MLResettable
        Parameters:
        seed - The seed value.
      • determineClasses

        public int[] determineClasses(MLData input)
        Determine the classes for the specified input.
        Parameters:
        input - The input.
        Returns:
        An array of class indexes.
      • classify

        public int classify(MLData input)
        Classify the input.
        Specified by:
        classify in interface MLClassification
        Parameters:
        input - The input to classify.
        Returns:
        The group that the data was classified into.
      • getClassificationTarget

        public int getClassificationTarget()
        Get the classification target.
        Returns:
        The index of the classification target.
      • isInputPresent

        public boolean isInputPresent(int idx)
        Determine if the specified input is present.
        Parameters:
        idx - The index of the input.
        Returns:
        True, if the input is present.
      • defineClassificationStructure

        public void defineClassificationStructure(String line)
        Define a classification structure of the form P(A|B) = P(C)
        Parameters:
        line -
      • getClassificationTargetEvent

        public BayesianEvent getClassificationTargetEvent()
        Returns:
        The classification target.
      • calculateError

        public double calculateError(MLDataSet data)
        Calculate the error of the ML method, given a dataset.
        Specified by:
        calculateError in interface MLError
        Parameters:
        data - The dataset.
        Returns:
        The error.
      • getClassificationStructure

        public String getClassificationStructure()
        Returns:
        Returns a string representation of the classification structure. Of the form P(a|b,c,d)
      • hasValidClassificationTarget

        public boolean hasValidClassificationTarget()
        Returns:
        True if this network has a valid classification target.

SCaVis 1.7 © jWork.org