|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectweka.classifiers.Classifier
weka.classifiers.rules.DecisionTable
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.
Nested Class Summary | |
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. |
Field Summary | |
private boolean |
m_classIsNominal
Class is nominal |
private int |
m_CVFolds
Number of folds for cross validating feature sets |
private boolean |
m_debug
Output debug info |
private int[] |
m_decisionFeatures
Holds the final feature set |
private Remove |
m_delTransform
Filter used to remove columns discarded by feature selection |
private boolean |
m_displayRules
Display Rules |
private Filter |
m_disTransform
Discretization filter |
private java.util.Hashtable |
m_entries
The hashtable used to hold training instances |
private IBk |
m_ibk
IB1 used to classify non matching instances rather than majority class |
private double |
m_majority
Holds the majority class |
private int |
m_maxStale
Maximum number of fully expanded non improving subsets for a best first search. |
private int |
m_numAttributes
The number of attributes in the dataset |
private int |
m_numInstances
The number of instances in the dataset |
private java.util.Random |
m_rr
Random numbers for use in cross validation |
private Instances |
m_theInstances
Holds the training instances |
private boolean |
m_useIBk
Use the IBk classifier rather than majority class |
Fields inherited from class weka.classifiers.Classifier |
m_Debug |
Constructor Summary | |
DecisionTable()
Constructor for a DecisionTable |
Method Summary | |
private void |
best_first()
Does a best first search |
void |
buildClassifier(Instances data)
Generates the classifier. |
(package private) double |
classifyFoldCV(Instances fold,
int[] fs)
Calculates the accuracy on a test fold for internal cross validation of feature sets |
(package private) double |
classifyInstanceLeaveOneOut(Instance instance,
double[] instA)
Classifies an instance for internal leave one out cross validation of feature sets |
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 |
private double |
estimateAccuracy(java.util.BitSet feature_set,
int num_atts)
Evaluates a feature subset by cross validation |
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 |
private void |
insertIntoTable(Instance inst,
double[] instA)
Inserts an instance into the hash table |
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 |
private java.lang.String |
printSub(java.util.BitSet sub)
Returns a String representation of a feature subset |
protected void |
resetOptions()
Resets the options. |
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 |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
private java.util.Hashtable m_entries
private int[] m_decisionFeatures
private Filter m_disTransform
private Remove m_delTransform
private IBk m_ibk
private Instances m_theInstances
private int m_numAttributes
private int m_numInstances
private boolean m_classIsNominal
private boolean m_debug
private boolean m_useIBk
private boolean m_displayRules
private int m_maxStale
private int m_CVFolds
private java.util.Random m_rr
private double m_majority
Constructor Detail |
public DecisionTable()
Method Detail |
public java.lang.String globalInfo()
private void insertIntoTable(Instance inst, double[] instA) throws java.lang.Exception
inst
- instance to be inserted
java.lang.Exception
- if the instance can't be inserteddouble classifyInstanceLeaveOneOut(Instance instance, double[] instA) throws java.lang.Exception
instance
- instance to be "left out" and classifiedinstA
- feature values of the selected features for the instance
java.lang.Exception
double classifyFoldCV(Instances fold, int[] fs) throws java.lang.Exception
fold
- set of instances to be "left out" and classifiedfs
- currently selected feature set
java.lang.Exception
private double estimateAccuracy(java.util.BitSet feature_set, int num_atts) throws java.lang.Exception
feature_set
- the subset to be evaluatednum_atts
- the number of attributes in the subset
java.lang.Exception
- if subset can't be evaluatedprivate java.lang.String printSub(java.util.BitSet sub)
sub
- BitSet representation of a subset
private void best_first() throws java.lang.Exception
java.lang.Exception
protected void resetOptions()
public java.util.Enumeration listOptions()
listOptions
in interface OptionHandler
listOptions
in class Classifier
public java.lang.String crossValTipText()
public void setCrossVal(int folds)
folds
- the number of foldspublic int getCrossVal()
public java.lang.String maxStaleTipText()
public void setMaxStale(int stale)
stale
- the number of nodespublic int getMaxStale()
public java.lang.String useIBkTipText()
public void setUseIBk(boolean ibk)
ibk
- true if IBk is to be usedpublic boolean getUseIBk()
public java.lang.String displayRulesTipText()
public void setDisplayRules(boolean rules)
rules
- true if rules are to be printedpublic boolean getDisplayRules()
public void setOptions(java.lang.String[] options) throws java.lang.Exception
-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.
setOptions
in interface OptionHandler
setOptions
in class Classifier
options
- the list of options as an array of strings
java.lang.Exception
- if an option is not supportedpublic java.lang.String[] getOptions()
getOptions
in interface OptionHandler
getOptions
in class Classifier
public void buildClassifier(Instances data) throws java.lang.Exception
buildClassifier
in class Classifier
data
- set of instances serving as training data
java.lang.Exception
- if the classifier has not been generated successfullypublic double[] distributionForInstance(Instance instance) throws java.lang.Exception
distributionForInstance
in class Classifier
instance
- the instance to be classified
java.lang.Exception
- if distribution can't be computedpublic java.lang.String printFeatures()
public double measureNumRules()
public java.util.Enumeration enumerateMeasures()
enumerateMeasures
in interface AdditionalMeasureProducer
public double getMeasure(java.lang.String additionalMeasureName)
getMeasure
in interface AdditionalMeasureProducer
additionalMeasureName
- the name of the measure to query for its value
java.lang.IllegalArgumentException
- if the named measure is not supportedpublic java.lang.String toString()
public static void main(java.lang.String[] argv)
argv
- the command-line options
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |