weka.classifiers.rules
Class DecisionTable

java.lang.Object
  extended byweka.classifiers.Classifier
      extended byweka.classifiers.rules.DecisionTable
All Implemented Interfaces:
AdditionalMeasureProducer, java.lang.Cloneable, OptionHandler, java.io.Serializable, WeightedInstancesHandler

public class DecisionTable
extends Classifier
implements OptionHandler, WeightedInstancesHandler, AdditionalMeasureProducer

Class for building and using a simple decision table majority classifier. For more information see:

Kohavi R. (1995). The Power of Decision Tables. In Proc European Conference on Machine Learning.

Valid options are:

-S num
Number of fully expanded non improving subsets to consider before terminating a best first search. (Default = 5)

-X num
Use cross validation to evaluate features. Use number of folds = 1 for leave one out CV. (Default = leave one out CV)

-I
Use nearest neighbour instead of global table majority.

-R
Prints the decision table.

Version:
$Revision: 1.29 $
Author:
Mark Hall (mhall@cs.waikato.ac.nz)
See Also:
Serialized Form

Nested Class Summary
static class DecisionTable.hashKey
          Class providing keys to the hash table
 class DecisionTable.Link
          Class for a node in a linked list.
 class DecisionTable.LinkedList
          Class for handling a linked list.
 
Constructor Summary
DecisionTable()
          Constructor for a DecisionTable
 
Method Summary
 void buildClassifier(Instances data)
          Generates the classifier.
 java.lang.String crossValTipText()
          Returns the tip text for this property
 java.lang.String displayRulesTipText()
          Returns the tip text for this property
 double[] distributionForInstance(Instance instance)
          Calculates the class membership probabilities for the given test instance.
 java.util.Enumeration enumerateMeasures()
          Returns an enumeration of the additional measure names
 int getCrossVal()
          Gets the number of folds for cross validation
 boolean getDisplayRules()
          Gets whether rules are being printed
 int getMaxStale()
          Gets the number of non improving decision tables
 double getMeasure(java.lang.String additionalMeasureName)
          Returns the value of the named measure
 java.lang.String[] getOptions()
          Gets the current settings of the classifier.
 boolean getUseIBk()
          Gets whether IBk is being used instead of the majority class
 java.lang.String globalInfo()
          Returns a string describing classifier
 java.util.Enumeration listOptions()
          Returns an enumeration describing the available options.
static void main(java.lang.String[] argv)
          Main method for testing this class.
 java.lang.String maxStaleTipText()
          Returns the tip text for this property
 double measureNumRules()
          Returns the number of rules
 java.lang.String printFeatures()
          Returns a string description of the features selected
 void setCrossVal(int folds)
          Sets the number of folds for cross validation (1 = leave one out)
 void setDisplayRules(boolean rules)
          Sets whether rules are to be printed
 void setMaxStale(int stale)
          Sets the number of non improving decision tables to consider before abandoning the search.
 void setOptions(java.lang.String[] options)
          Parses the options for this object.
 void setUseIBk(boolean ibk)
          Sets whether IBk should be used instead of the majority class
 java.lang.String toString()
          Returns a description of the classifier.
 java.lang.String useIBkTipText()
          Returns the tip text for this property
 
Methods inherited from class weka.classifiers.Classifier
classifyInstance, debugTipText, forName, getDebug, makeCopies, setDebug
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DecisionTable

public DecisionTable()
Constructor for a DecisionTable

Method Detail

globalInfo

public java.lang.String globalInfo()
Returns a string describing classifier

Returns:
a description suitable for displaying in the explorer/experimenter gui

listOptions

public java.util.Enumeration listOptions()
Returns an enumeration describing the available options.

Specified by:
listOptions in interface OptionHandler
Overrides:
listOptions in class Classifier
Returns:
an enumeration of all the available options.

crossValTipText

public java.lang.String crossValTipText()
Returns the tip text for this property

Returns:
tip text for this property suitable for displaying in the explorer/experimenter gui

setCrossVal

public void setCrossVal(int folds)
Sets the number of folds for cross validation (1 = leave one out)

Parameters:
folds - the number of folds

getCrossVal

public int getCrossVal()
Gets the number of folds for cross validation

Returns:
the number of cross validation folds

maxStaleTipText

public java.lang.String maxStaleTipText()
Returns the tip text for this property

Returns:
tip text for this property suitable for displaying in the explorer/experimenter gui

setMaxStale

public void setMaxStale(int stale)
Sets the number of non improving decision tables to consider before abandoning the search.

Parameters:
stale - the number of nodes

getMaxStale

public int getMaxStale()
Gets the number of non improving decision tables

Returns:
the number of non improving decision tables

useIBkTipText

public java.lang.String useIBkTipText()
Returns the tip text for this property

Returns:
tip text for this property suitable for displaying in the explorer/experimenter gui

setUseIBk

public void setUseIBk(boolean ibk)
Sets whether IBk should be used instead of the majority class

Parameters:
ibk - true if IBk is to be used

getUseIBk

public boolean getUseIBk()
Gets whether IBk is being used instead of the majority class

Returns:
true if IBk is being used

displayRulesTipText

public java.lang.String displayRulesTipText()
Returns the tip text for this property

Returns:
tip text for this property suitable for displaying in the explorer/experimenter gui

setDisplayRules

public void setDisplayRules(boolean rules)
Sets whether rules are to be printed

Parameters:
rules - true if rules are to be printed

getDisplayRules

public boolean getDisplayRules()
Gets whether rules are being printed

Returns:
true if rules are being printed

setOptions

public void setOptions(java.lang.String[] options)
                throws java.lang.Exception
Parses the options for this object. Valid options are:

-S num
Number of fully expanded non improving subsets to consider before terminating a best first search. (Default = 5)

-X num
Use cross validation to evaluate features. Use number of folds = 1 for leave one out CV. (Default = leave one out CV)

-I
Use nearest neighbour instead of global table majority.

-R
Prints the decision table.

Specified by:
setOptions in interface OptionHandler
Overrides:
setOptions in class Classifier
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 classifier.

Specified by:
getOptions in interface OptionHandler
Overrides:
getOptions in class Classifier
Returns:
an array of strings suitable for passing to setOptions

buildClassifier

public void buildClassifier(Instances data)
                     throws java.lang.Exception
Generates the classifier.

Specified by:
buildClassifier in class Classifier
Parameters:
data - set of instances serving as training data
Throws:
java.lang.Exception - if the classifier has not been generated successfully

distributionForInstance

public double[] distributionForInstance(Instance instance)
                                 throws java.lang.Exception
Calculates the class membership probabilities for the given test instance.

Overrides:
distributionForInstance in class Classifier
Parameters:
instance - the instance to be classified
Returns:
predicted class probability distribution
Throws:
java.lang.Exception - if distribution can't be computed

printFeatures

public java.lang.String printFeatures()
Returns a string description of the features selected

Returns:
a string of features

measureNumRules

public double measureNumRules()
Returns the number of rules

Returns:
the number of rules

enumerateMeasures

public java.util.Enumeration enumerateMeasures()
Returns an enumeration of the additional measure names

Specified by:
enumerateMeasures in interface AdditionalMeasureProducer
Returns:
an enumeration of the measure names

getMeasure

public double getMeasure(java.lang.String additionalMeasureName)
Returns the value of the named measure

Specified by:
getMeasure in interface AdditionalMeasureProducer
Parameters:
additionalMeasureName - the name of the measure to query for its value
Returns:
the value of the named measure
Throws:
java.lang.IllegalArgumentException - if the named measure is not supported

toString

public java.lang.String toString()
Returns a description of the classifier.

Returns:
a description of the classifier as a string.

main

public static void main(java.lang.String[] argv)
Main method for testing this class.

Parameters:
argv - the command-line options