Class LocalScoreSearchAlgorithm
- java.lang.Object
-
- weka.classifiers.bayes.net.search.SearchAlgorithm
-
- weka.classifiers.bayes.net.search.local.LocalScoreSearchAlgorithm
-
- All Implemented Interfaces:
java.io.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: 5196 $
- Author:
- Remco Bouckaert
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static Tag[]
TAGS_SCORE_TYPE
the score types
-
Constructor Summary
Constructors Constructor Description LocalScoreSearchAlgorithm()
default constructorLocalScoreSearchAlgorithm(BayesNet bayesNet, Instances instances)
constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
buildStructure(BayesNet bayesNet, Instances instances)
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.double
calcNodeScore(int nNode)
Calc Node Score for given parent setdouble
calcScoreWithExtraParent(int nNode, int nCandidateParent)
Calc Node Score With AddedParentdouble
calcScoreWithMissingParent(int nNode, int nCandidateParent)
Calc Node Score With Parent Deletedboolean
getMarkovBlanketClassifier()
java.lang.String[]
getOptions()
Gets the current settings of the search algorithm.java.lang.String
getRevision()
Returns the revision string.SelectedTag
getScoreType()
get quality measure to be used in searching for networks.java.lang.String
globalInfo()
This will return a string describing the search algorithm.java.util.Enumeration
listOptions()
Returns an enumeration describing the available optionsdouble
logScore(int nType)
logScore returns the log of the quality of a network (e.g.java.lang.String
markovBlanketClassifierTipText()
java.lang.String
scoreTypeTipText()
void
setMarkovBlanketClassifier(boolean bMarkovBlanketClassifier)
void
setOptions(java.lang.String[] options)
Parses a given list of options.void
setScoreType(SelectedTag newScoreType)
set quality measure to be used in searching for networks.-
Methods inherited from class weka.classifiers.bayes.net.search.SearchAlgorithm
initAsNaiveBayesTipText, maxNrOfParentsTipText, toString
-
-
-
-
Field Detail
-
TAGS_SCORE_TYPE
public static final Tag[] TAGS_SCORE_TYPE
the score types
-
-
Method Detail
-
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 java.lang.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 classSearchAlgorithm
- Parameters:
bayesNet
- the networkinstances
- the data to use- Throws:
java.lang.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 calculatenCandidateParent
- 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 calculatenCandidateParent
- 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 java.util.Enumeration listOptions()
Returns an enumeration describing the available options- Specified by:
listOptions
in interfaceOptionHandler
- Overrides:
listOptions
in classSearchAlgorithm
- Returns:
- an enumeration of all the available options
-
setOptions
public void setOptions(java.lang.String[] options) throws java.lang.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 interfaceOptionHandler
- Overrides:
setOptions
in classSearchAlgorithm
- Parameters:
options
- the list of options as an array of strings- Throws:
java.lang.Exception
- if an option is not supported
-
getOptions
public java.lang.String[] getOptions()
Gets the current settings of the search algorithm.- Specified by:
getOptions
in interfaceOptionHandler
- Overrides:
getOptions
in classSearchAlgorithm
- Returns:
- an array of strings suitable for passing to setOptions
-
scoreTypeTipText
public java.lang.String scoreTypeTipText()
- Returns:
- a string to describe the ScoreType option.
-
markovBlanketClassifierTipText
public java.lang.String markovBlanketClassifierTipText()
- Returns:
- a string to describe the MarkovBlanketClassifier option.
-
globalInfo
public java.lang.String globalInfo()
This will return a string describing the search algorithm.- Returns:
- The string.
-
getRevision
public java.lang.String getRevision()
Returns the revision string.- Specified by:
getRevision
in interfaceRevisionHandler
- Overrides:
getRevision
in classSearchAlgorithm
- Returns:
- the revision
-
-