weka.classifiers.bayes.net.search.global
Class GlobalScoreSearchAlgorithm

java.lang.Object
  extended byweka.classifiers.bayes.net.search.SearchAlgorithm
      extended byweka.classifiers.bayes.net.search.global.GlobalScoreSearchAlgorithm
All Implemented Interfaces:
OptionHandler, java.io.Serializable
Direct Known Subclasses:
GeneticSearch, HillClimber, K2, SimulatedAnnealing, TAN

public class GlobalScoreSearchAlgorithm
extends SearchAlgorithm

The CVSearchAlgorithm class supports Bayes net structure search algorithms that are based on cross validation (as opposed to for example score based of conditional independence based search algorithms).

Version:
$Revision: 1.5 $
Author:
Remco Bouckaert
See Also:
Serialized Form

Field Summary
static Tag[] TAGS_CV_TYPE
           
 
Constructor Summary
GlobalScoreSearchAlgorithm()
           
 
Method Summary
 double calcScore(BayesNet bayesNet)
          performCV returns the accuracy calculated using cross validation.
 double calcScoreWithExtraParent(int nNode, int nCandidateParent)
          Calc Node Score With Added Parent
 double calcScoreWithMissingParent(int nNode, int nCandidateParent)
          Calc Node Score With Parent Deleted
 double calcScoreWithReversedParent(int nNode, int nCandidateParent)
          Calc Node Score With Arrow reversed
 double cumulativeCV(BayesNet bayesNet)
          CumulativeCV returns the accuracy calculated using cumulative cross validation.
 java.lang.String CVTypeTipText()
           
 SelectedTag getCVType()
          get cross validation strategy to be used in searching for networks.
 java.lang.String[] getOptions()
          Gets the current settings of the search algorithm.
 boolean getUseProb()
           
 java.lang.String globalInfo()
          This will return a string describing the search algorithm.
 double kFoldCV(BayesNet bayesNet, int nNrOfFolds)
          kFoldCV uses k-fold cross validation to measure the accuracy of a Bayes network classifier.
 double leaveOneOutCV(BayesNet bayesNet)
          LeaveOneOutCV returns the accuracy calculated using Leave One Out cross validation.
 java.util.Enumeration listOptions()
          Returns an enumeration describing the available options
 void setCVType(SelectedTag newCVType)
          set cross validation strategy to be used in searching for networks.
 void setOptions(java.lang.String[] options)
          Parses a given list of options.
 void setUseProb(boolean useProb)
           
 java.lang.String useProbTipText()
           
 
Methods inherited from class weka.classifiers.bayes.net.search.SearchAlgorithm
buildStructure, getMarkovBlanketClassifier, initAsNaiveBayesTipText, markovBlanketClassifierTipText, maxNrOfParentsTipText, setMarkovBlanketClassifier, toString
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

TAGS_CV_TYPE

public static final Tag[] TAGS_CV_TYPE
Constructor Detail

GlobalScoreSearchAlgorithm

public GlobalScoreSearchAlgorithm()
Method Detail

calcScore

public double calcScore(BayesNet bayesNet)
                 throws java.lang.Exception
performCV returns the accuracy calculated using cross validation. The dataset used is m_Instances associated with the Bayes Network.

Parameters:
bayesNet - : Bayes Network containing structure to evaluate
Returns:
accuracy (in interval 0..1) measured using cv.
Throws:
java.lang.Exception - whn m_nCVType is invalided + exceptions passed on by updateClassifier

calcScoreWithExtraParent

public double calcScoreWithExtraParent(int nNode,
                                       int nCandidateParent)
                                throws java.lang.Exception
Calc Node Score With Added Parent

Parameters:
nNode - node for which the score is calculate
nCandidateParent - candidate parent to add to the existing parent set
Returns:
log score
Throws:
java.lang.Exception

calcScoreWithMissingParent

public double calcScoreWithMissingParent(int nNode,
                                         int nCandidateParent)
                                  throws java.lang.Exception
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
Throws:
java.lang.Exception

calcScoreWithReversedParent

public double calcScoreWithReversedParent(int nNode,
                                          int nCandidateParent)
                                   throws java.lang.Exception
Calc Node Score With Arrow reversed

Parameters:
nNode - node for which the score is calculate
nCandidateParent - candidate parent to delete from the existing parent set
Returns:
log score
Throws:
java.lang.Exception

leaveOneOutCV

public double leaveOneOutCV(BayesNet bayesNet)
                     throws java.lang.Exception
LeaveOneOutCV returns the accuracy calculated using Leave One Out cross validation. The dataset used is m_Instances associated with the Bayes Network.

Parameters:
bayesNet - : Bayes Network containing structure to evaluate
Returns:
accuracy (in interval 0..1) measured using leave one out cv.
Throws:
java.lang.Exception - passed on by updateClassifier

cumulativeCV

public double cumulativeCV(BayesNet bayesNet)
                    throws java.lang.Exception
CumulativeCV returns the accuracy calculated using cumulative cross validation. The idea is to run through the data set and try to classify each of the instances based on the previously seen data. The data set used is m_Instances associated with the Bayes Network.

Parameters:
bayesNet - : Bayes Network containing structure to evaluate
Returns:
accuracy (in interval 0..1) measured using leave one out cv.
Throws:
java.lang.Exception - passed on by updateClassifier

kFoldCV

public double kFoldCV(BayesNet bayesNet,
                      int nNrOfFolds)
               throws java.lang.Exception
kFoldCV uses k-fold cross validation to measure the accuracy of a Bayes network classifier.

Parameters:
bayesNet - : Bayes Network containing structure to evaluate
nNrOfFolds - : the number of folds k to perform k-fold cv
Returns:
accuracy (in interval 0..1) measured using leave one out cv.
Throws:
java.lang.Exception - passed on by updateClassifier

getUseProb

public boolean getUseProb()
Returns:
use probabilities or not in accuracy estimate

setUseProb

public void setUseProb(boolean useProb)
Parameters:
useProb - : use probabilities or not in accuracy estimate

setCVType

public void setCVType(SelectedTag newCVType)
set cross validation strategy to be used in searching for networks.

Parameters:
newCVType - : cross validation strategy

getCVType

public SelectedTag getCVType()
get cross validation strategy to be used in searching for networks.

Returns:
cross validation strategy

listOptions

public java.util.Enumeration 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(java.lang.String[] options)
                throws java.lang.Exception
Parses a given list of options. Valid options are:

For other options see search algorithm.

Specified by:
setOptions in interface OptionHandler
Overrides:
setOptions in class SearchAlgorithm
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 interface OptionHandler
Overrides:
getOptions in class SearchAlgorithm
Returns:
an array of strings suitable for passing to setOptions

CVTypeTipText

public java.lang.String CVTypeTipText()
Returns:
a string to describe the CVType option.

useProbTipText

public java.lang.String useProbTipText()
Returns:
a string to describe the UseProb option.

globalInfo

public java.lang.String globalInfo()
This will return a string describing the search algorithm.

Returns:
The string.