Class LocalScoreSearchAlgorithm

java.lang.Object
weka.classifiers.bayes.net.search.SearchAlgorithm
weka.classifiers.bayes.net.search.local.LocalScoreSearchAlgorithm
All Implemented Interfaces:
Serializable, OptionHandler, RevisionHandler
Direct Known Subclasses:
CISearchAlgorithm, GeneticSearch, HillClimber, K2, SimulatedAnnealing, TAN

public class LocalScoreSearchAlgorithm extends SearchAlgorithm
The ScoreBasedSearchAlgorithm class supports Bayes net structure search algorithms that are based on maximizing scores (as opposed to for example conditional independence based search algorithms).

Valid options are:

 -mbc
  Applies a Markov Blanket correction to the network structure, 
  after a network structure is learned. This ensures that all 
  nodes in the network are part of the Markov blanket of the 
  classifier node.
 
 -S [BAYES|MDL|ENTROPY|AIC|CROSS_CLASSIC|CROSS_BAYES]
  Score type (BAYES, BDeu, MDL, ENTROPY and AIC)
 
Version:
$Revision: 10378 $
Author:
Remco Bouckaert
See Also:
  • Field Details

    • TAGS_SCORE_TYPE

      public static final Tag[] TAGS_SCORE_TYPE
      the score types
  • Constructor Details

    • LocalScoreSearchAlgorithm

      public LocalScoreSearchAlgorithm()
      default constructor
    • LocalScoreSearchAlgorithm

      public LocalScoreSearchAlgorithm(BayesNet bayesNet, Instances instances)
      constructor
      Parameters:
      bayesNet - the network
      instances - the data
  • Method Details

    • logScore

      public double logScore(int nType)
      logScore returns the log of the quality of a network (e.g. the posterior probability of the network, or the MDL value).
      Parameters:
      nType - score type (Bayes, MDL, etc) to calculate score with
      Returns:
      log score.
    • buildStructure

      public void buildStructure(BayesNet bayesNet, Instances instances) throws Exception
      buildStructure determines the network structure/graph of the network with the K2 algorithm, restricted by its initial structure (which can be an empty graph, or a Naive Bayes graph.
      Overrides:
      buildStructure in class SearchAlgorithm
      Parameters:
      bayesNet - the network
      instances - the data to use
      Throws:
      Exception - if something goes wrong
    • calcNodeScore

      public double calcNodeScore(int nNode)
      Calc Node Score for given parent set
      Parameters:
      nNode - node for which the score is calculate
      Returns:
      log score
    • calcScoreWithExtraParent

      public double calcScoreWithExtraParent(int nNode, int nCandidateParent)
      Calc Node Score With AddedParent
      Parameters:
      nNode - node for which the score is calculate
      nCandidateParent - candidate parent to add to the existing parent set
      Returns:
      log score
    • calcScoreWithMissingParent

      public double calcScoreWithMissingParent(int nNode, int nCandidateParent)
      Calc Node Score With Parent Deleted
      Parameters:
      nNode - node for which the score is calculate
      nCandidateParent - candidate parent to delete from the existing parent set
      Returns:
      log score
    • setScoreType

      public void setScoreType(SelectedTag newScoreType)
      set quality measure to be used in searching for networks.
      Parameters:
      newScoreType - the new score type
    • getScoreType

      public SelectedTag getScoreType()
      get quality measure to be used in searching for networks.
      Returns:
      quality measure
    • setMarkovBlanketClassifier

      public void setMarkovBlanketClassifier(boolean bMarkovBlanketClassifier)
      Parameters:
      bMarkovBlanketClassifier -
    • getMarkovBlanketClassifier

      public boolean getMarkovBlanketClassifier()
      Returns:
    • listOptions

      public Enumeration<Option> listOptions()
      Returns an enumeration describing the available options
      Specified by:
      listOptions in interface OptionHandler
      Overrides:
      listOptions in class SearchAlgorithm
      Returns:
      an enumeration of all the available options
    • setOptions

      public void setOptions(String[] options) throws Exception
      Parses a given list of options.

      Valid options are:

       -mbc
        Applies a Markov Blanket correction to the network structure, 
        after a network structure is learned. This ensures that all 
        nodes in the network are part of the Markov blanket of the 
        classifier node.
       
       -S [BAYES|MDL|ENTROPY|AIC|CROSS_CLASSIC|CROSS_BAYES]
        Score type (BAYES, BDeu, MDL, ENTROPY and AIC)
       
      Specified by:
      setOptions in interface OptionHandler
      Overrides:
      setOptions in class SearchAlgorithm
      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 search algorithm.
      Specified by:
      getOptions in interface OptionHandler
      Overrides:
      getOptions in class SearchAlgorithm
      Returns:
      an array of strings suitable for passing to setOptions
    • scoreTypeTipText

      public String scoreTypeTipText()
      Returns:
      a string to describe the ScoreType option.
    • markovBlanketClassifierTipText

      public String markovBlanketClassifierTipText()
      Returns:
      a string to describe the MarkovBlanketClassifier option.
    • globalInfo

      public String globalInfo()
      This will return a string describing the search algorithm.
      Returns:
      The string.
    • getRevision

      public String getRevision()
      Returns the revision string.
      Specified by:
      getRevision in interface RevisionHandler
      Overrides:
      getRevision in class SearchAlgorithm
      Returns:
      the revision